更改文件架构
This commit is contained in:
8
Packages/Common~/Scripts/Provider/Editor.meta
Normal file
8
Packages/Common~/Scripts/Provider/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ced600d8f5e979c4f94267505b57689b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "Editor.BITKit.Provider"
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 959137683f1db044bb5d6eebd7063785
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Packages/Common~/Scripts/Provider/Multiplex.cs
Normal file
15
Packages/Common~/Scripts/Provider/Multiplex.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public abstract class Multiplex : Provider, IProvider<bool>
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[SerializeField] string remarks;
|
||||
#endif
|
||||
public bool active;
|
||||
public bool Get() => active;
|
||||
public void Set(bool x) => active = x;
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Provider/Multiplex.cs.meta
Normal file
11
Packages/Common~/Scripts/Provider/Multiplex.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d53df81557a4eaf4d99c5f40d55b97f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
28
Packages/Common~/Scripts/Provider/MultiplexGroup.cs
Normal file
28
Packages/Common~/Scripts/Provider/MultiplexGroup.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class MultiplexGroup : Provider<int>
|
||||
{
|
||||
public int index = 0;
|
||||
public List<Multiplex> list = new();
|
||||
void Start()
|
||||
{
|
||||
Set(index);
|
||||
}
|
||||
public override void Set(int t)
|
||||
{
|
||||
index = t;
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.active = false;
|
||||
}
|
||||
list[index].active = true;
|
||||
}
|
||||
public override int Get()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Provider/MultiplexGroup.cs.meta
Normal file
11
Packages/Common~/Scripts/Provider/MultiplexGroup.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d5b551c079b3d943b47ba1eb40099c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
Packages/Common~/Scripts/Provider/MultiplexInput.cs
Normal file
17
Packages/Common~/Scripts/Provider/MultiplexInput.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class MultiplexInput : Multiplex
|
||||
{
|
||||
public Provider output;
|
||||
public override void Set<T>(T obj)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
output.Set<T>(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Provider/MultiplexInput.cs.meta
Normal file
11
Packages/Common~/Scripts/Provider/MultiplexInput.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6da7edff22322c4428fa692047e22987
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
38
Packages/Common~/Scripts/Provider/MultiplexOutput.cs
Normal file
38
Packages/Common~/Scripts/Provider/MultiplexOutput.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit
|
||||
{
|
||||
public class MultiplexOutput : Multiplex
|
||||
{
|
||||
public List<Provider> providers = new();
|
||||
public string outputType = typeof(MultiplexOutput).Name;
|
||||
public override async void Set<T>(T t)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
try
|
||||
{
|
||||
await UniTask.SwitchToTaskPool();
|
||||
foreach (var genericProvider in providers)
|
||||
{
|
||||
if (genericProvider is IProvider<T> provider)
|
||||
{
|
||||
provider.Set(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
genericProvider.Set(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
}
|
||||
outputType = typeof(T).Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Provider/MultiplexOutput.cs.meta
Normal file
11
Packages/Common~/Scripts/Provider/MultiplexOutput.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dac882f4d1e1fb540ab3e8ab1612450b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user