diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleAssets.cs b/Packages/Tools/Runtime/ModuleCore/ModuleAssets.cs deleted file mode 100644 index f0340e9..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModuleAssets.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace MuHua { - /// - /// 资源模块 - /// - public class ModuleAssets : Module> { - protected List datas = new List(); - - /// 更改事件 - public virtual event Action> OnChange; - /// 数据列表 - public virtual List Datas => datas; - /// 数据计数 - public virtual int Count => Datas.Count; - /// 数据操作 Datas[index]; - - /// 添加数据 - public virtual void Add(Data data) { Datas.Add(data); OnChange?.Invoke(this); } - /// 添加数据 - public virtual void Add(IList data) { Datas.AddRange(data); OnChange?.Invoke(this); } - /// 删除数据 - public virtual void Remove(Data data) { Datas.Remove(data); OnChange?.Invoke(this); } - /// 清除数据 - public virtual void Clear() { Datas.Clear(); OnChange?.Invoke(this); } - - /// 保存数据 - public virtual void Save() { throw new NotImplementedException(); } - /// 加载数据 - public virtual void Load() { throw new NotImplementedException(); } - - /// 循环列表 - public virtual void ForEach(Action action) => Datas.ForEach(action); - } - /// - /// 资源模块工具 - /// - public static class AssetsTool { - /// 头尾循环标准化索引 - public static Data LoopIndex(this ModuleAssets assets, int index) { - return assets[LoopIndex(index, assets.Count)]; - } - /// 头尾循环标准化索引 - public static Data LoopIndex(this List list, int index) { - return list[LoopIndex(index, list.Count)]; - } - /// 头尾循环标准化索引 - public static Data LoopIndex(this Data[] array, int index) { - return array[LoopIndex(index, array.Length)]; - } - /// 头尾循环标准化索引 - public static int LoopIndex(int index, int maxIndex) { - return index % maxIndex; - } - } -} \ No newline at end of file diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleAssets.cs.meta b/Packages/Tools/Runtime/ModuleCore/ModuleAssets.cs.meta deleted file mode 100644 index 001217e..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModuleAssets.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f240e58226b9d1440b23f97be93c4f00 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleData.cs b/Packages/Tools/Runtime/ModuleCore/ModuleData.cs deleted file mode 100644 index 21120d5..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModuleData.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace MuHua { - /// - /// 数据 - /// - public abstract class ModuleData where T : ModuleData { - /// 可视化对象 - public ModulePrefab visual; - } -} \ No newline at end of file diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleData.cs.meta b/Packages/Tools/Runtime/ModuleCore/ModuleData.cs.meta deleted file mode 100644 index 72513fa..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModuleData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6266364f7baf1e741b8951d0ae0a1608 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleHandle.cs b/Packages/Tools/Runtime/ModuleCore/ModuleHandle.cs deleted file mode 100644 index 9113803..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModuleHandle.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace MuHua { - /// - /// 事件处理器 - /// - public class ModuleHandle : Module> { - /// 数据 - protected Data value; - - /// 当前数据 - public virtual Data Current => value; - /// 当前数据是否有效 - public virtual bool IsValid => Current != null; - - /// 改变当前数据 Event - public virtual event Action OnChange; - /// 改变当前数据 - public virtual void Change() => OnChange?.Invoke(value); - /// 改变当前数据 - public virtual void Change(Data value) { this.value = value; Change(); } - } -} \ No newline at end of file diff --git a/Packages/Tools/Runtime/ModuleCore/ModulePrefab.cs b/Packages/Tools/Runtime/ModuleCore/ModulePrefab.cs deleted file mode 100644 index d975bc5..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModulePrefab.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace MuHua { - /// - /// 数据预制件 - /// - public abstract class ModulePrefab : MonoBehaviour where T : ModuleData { - /// 关联的数据 - protected T value; - - /// 关联的数据 - public virtual T Value => value; - /// 更新可视化内容 - public virtual void UpdateVisual(T value) => this.value = value; - } -} diff --git a/Packages/Tools/Runtime/ModuleCore/ModulePrefab.cs.meta b/Packages/Tools/Runtime/ModuleCore/ModulePrefab.cs.meta deleted file mode 100644 index 4350405..0000000 --- a/Packages/Tools/Runtime/ModuleCore/ModulePrefab.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fa7816f4efcec004e99b05e88149b6a0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleVisual.cs b/Packages/Tools/Runtime/ModuleCore/ModuleVisual.cs index b6ba746..156ad30 100644 --- a/Packages/Tools/Runtime/ModuleCore/ModuleVisual.cs +++ b/Packages/Tools/Runtime/ModuleCore/ModuleVisual.cs @@ -6,25 +6,7 @@ namespace MuHua { /// /// 数据可视化 /// - public class ModuleVisual : ModuleSingle> where T : ModuleData { - /// 生成空间 - public Transform space; - /// 数据预制件 - public Transform prefab; - - /// 替换旧的 - protected override void Awake() => Replace(); - - /// 更新可视化内容 - public virtual void UpdateVisual(T data) { - Create(ref data.visual, prefab, space); - data.visual.UpdateVisual(data); - } - /// 释放可视化内容 - public virtual void ReleaseVisual(T data) { - if (data.visual != null) { Destroy(data.visual.gameObject); } - data.visual = null; - } + public class ModuleVisual { /// 创建可视化内容 public static void Create(ref Type value, Transform original, Transform parent) { if (value != null) { return; } @@ -37,5 +19,9 @@ namespace MuHua { temp.gameObject.SetActive(true); return temp; } + /// 删除可视化内容 + public static void Remove(Type visual) where Type : Component { + if (visual != null) { GameObject.Destroy(visual.gameObject); } + } } } \ No newline at end of file diff --git a/Packages/Tools/Runtime/ModuleTools/PointerOverUIObject.cs b/Packages/Tools/Runtime/ModuleTools/PointerOverUIObject.cs new file mode 100644 index 0000000..6c9cc6b --- /dev/null +++ b/Packages/Tools/Runtime/ModuleTools/PointerOverUIObject.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.EventSystems; + +/// +/// 检测鼠标是否在UI上 +/// +public class PointerOverUIObject : MonoBehaviour { + + private static bool isValid; + + public static bool IsValid => isValid; + + private void Update() { +#if UNITY_STANDALONE + //电脑平台 + isValid = EventSystem.current.IsPointerOverGameObject(); +#elif UNITY_WEBGL + //WebGL平台 + isValid = EventSystem.current.IsPointerOverGameObject(); +#elif UNITY_ANDROID + //安卓平台 + isValid = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId); +#elif UNITY_IOS + //苹果平台 + isValid = EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId); +#endif + } + +} diff --git a/Packages/Tools/Runtime/ModuleCore/ModuleHandle.cs.meta b/Packages/Tools/Runtime/ModuleTools/PointerOverUIObject.cs.meta similarity index 83% rename from Packages/Tools/Runtime/ModuleCore/ModuleHandle.cs.meta rename to Packages/Tools/Runtime/ModuleTools/PointerOverUIObject.cs.meta index 93d39ec..04fa71d 100644 --- a/Packages/Tools/Runtime/ModuleCore/ModuleHandle.cs.meta +++ b/Packages/Tools/Runtime/ModuleTools/PointerOverUIObject.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7e27b368a7807c74987bd3cb5287968a +guid: cfb91cad7f01d164d9e35b15f9b2c7c8 MonoImporter: externalObjects: {} serializedVersion: 2