diff --git a/Assets/00.StaryEvoTools/Runtime.meta b/Assets/00.StaryEvoTools/Runtime.meta new file mode 100644 index 0000000..93a2533 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 53828c11e13a43aebc54801a2a342f84 +timeCreated: 1756370317 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool.meta b/Assets/00.StaryEvoTools/Runtime/Tool.meta new file mode 100644 index 0000000..3f51fad --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d11726814f336347b8828f1029dfad5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes.meta new file mode 100644 index 0000000..95fe0f8 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75d4c33e7e46b5c478f8e068ed9be6c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionCNAttribute.cs b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionCNAttribute.cs new file mode 100644 index 0000000..0b252a1 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionCNAttribute.cs @@ -0,0 +1,22 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + public class APIDescriptionCNAttribute : Attribute + { + public string Description { get; private set; } + + public APIDescriptionCNAttribute(string description) + { + Description = description; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionCNAttribute.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionCNAttribute.cs.meta new file mode 100644 index 0000000..0710b0a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionCNAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2c5538bb5e55498ba063f98c0c7a8800 +timeCreated: 1647422088 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionENAttribute.cs b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionENAttribute.cs new file mode 100644 index 0000000..b4b230a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionENAttribute.cs @@ -0,0 +1,23 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + public class APIDescriptionENAttribute : Attribute + { + public string Description { get; private set; } + + public APIDescriptionENAttribute(string description) + { + Description = description; + } + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionENAttribute.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionENAttribute.cs.meta new file mode 100644 index 0000000..f018dd4 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIDescriptionENAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 570b6aa696204dbc949fea41caf8fcae +timeCreated: 1647422110 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIExampleCodeAttribute.cs b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIExampleCodeAttribute.cs new file mode 100644 index 0000000..f2fea4b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIExampleCodeAttribute.cs @@ -0,0 +1,22 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + public class APIExampleCodeAttribute : Attribute + { + public string Code { get; private set; } + + public APIExampleCodeAttribute(string code) + { + Code = code; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIExampleCodeAttribute.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIExampleCodeAttribute.cs.meta new file mode 100644 index 0000000..62c4736 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/APIExampleCodeAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b48b349a950f405095cf304b9bde0338 +timeCreated: 1647424574 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/ClassAPIAttribute.cs b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/ClassAPIAttribute.cs new file mode 100644 index 0000000..24f27cb --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/ClassAPIAttribute.cs @@ -0,0 +1,24 @@ + +using System; + +namespace Stary.Evo +{ + [AttributeUsage(AttributeTargets.Class)] + public class ClassAPIAttribute : Attribute + { + public string DisplayMenuName { get; private set; } + public string GroupName { get; private set; } + + public int RenderOrder { get;private set; } + + public string DisplayClassName { get; private set; } + + public ClassAPIAttribute(string groupName, string displayMenuName,int renderOrder,string displayClassName = null) + { + GroupName = groupName; + DisplayMenuName = displayMenuName; + RenderOrder = renderOrder; + DisplayClassName = displayClassName; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/ClassAPIAttribute.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/ClassAPIAttribute.cs.meta new file mode 100644 index 0000000..8cfa49a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/ClassAPIAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 72248ec1038f4ce58ad2861e9b02aa52 +timeCreated: 1647404455 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/MethodAPIAttribute.cs b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/MethodAPIAttribute.cs new file mode 100644 index 0000000..b562b70 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/MethodAPIAttribute.cs @@ -0,0 +1,18 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + [AttributeUsage(AttributeTargets.Method)] + public class MethodAPIAttribute : Attribute + { + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/MethodAPIAttribute.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/MethodAPIAttribute.cs.meta new file mode 100644 index 0000000..54f3e17 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/MethodAPIAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5db430b6c4ac4de5a9836454125e0669 +timeCreated: 1647428627 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/PropertyAPIAttribute.cs b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/PropertyAPIAttribute.cs new file mode 100644 index 0000000..d2322f3 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/PropertyAPIAttribute.cs @@ -0,0 +1,18 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2022 liangxiegame UNDER MIT License + * + * http://qframework.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using System; + +namespace Stary.Evo +{ + [AttributeUsage(AttributeTargets.Property)] + public class PropertyAPIAttribute : Attribute + { + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/PropertyAPIAttribute.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/PropertyAPIAttribute.cs.meta new file mode 100644 index 0000000..b7c2829 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/Attributes/PropertyAPIAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ab3c662f56b4401eaad6594ef6182e75 +timeCreated: 1647515468 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit.meta new file mode 100644 index 0000000..c06c58b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0e595bb208aff00418dc5a646f5e5bae +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component.meta new file mode 100644 index 0000000..f579c21 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9bc0ac15207240f695c4ba3f35865240 +timeCreated: 1710224493 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs new file mode 100644 index 0000000..1ffab10 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs @@ -0,0 +1,24 @@ +/**************************************************************************** + * Copyright (c) 2015 - 2024 liangxiegame UNDER MIT License + * + * https://qStary.Evo.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDeselectUnityEvent: MonoBehaviour, IDeselectHandler + { + public UnityEvent OnDeselectEvent; + + public void OnDeselect(BaseEventData eventData) + { + OnDeselectEvent?.Invoke(eventData); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs.meta new file mode 100644 index 0000000..b40cf96 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnDeselectUnityEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5edff8e50ab84809afe6b9894eef68ab +timeCreated: 1710224509 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs new file mode 100644 index 0000000..bc6b4ea --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs @@ -0,0 +1,24 @@ +/**************************************************************************** + * Copyright (c) 2016 - 2024 liangxiegame UNDER MIT License + * + * https://qStary.Evo.cn + * https://github.com/liangxiegame/QFramework + * https://gitee.com/liangxiegame/QFramework + ****************************************************************************/ + +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnSelectUnityEvent : MonoBehaviour, ISelectHandler + { + public UnityEvent OnSelectEvent; + + public void OnSelect(BaseEventData eventData) + { + OnSelectEvent?.Invoke(eventData); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs.meta new file mode 100644 index 0000000..4257f79 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Component/OnSelectUnityEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b73c32a61ddd4b469f20ad0f287b2a9e +timeCreated: 1710224585 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem.meta new file mode 100644 index 0000000..e3dde46 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9a4d4fb049e264d7585467dc91a94f28 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs new file mode 100644 index 0000000..9432d81 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; + +namespace Stary.Evo +{ + public interface IEasyEvent + { + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = () => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger() + { + mOnEvent?.Invoke(); + } + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = e => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger(T t) + { + mOnEvent?.Invoke(t); + } + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = (t, k) => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger(T t, K k) + { + mOnEvent?.Invoke(t, k); + } + } + + public class EasyEvent : IEasyEvent + { + private Action mOnEvent = (t, k, s) => { }; + + public IUnRegister Register(Action onEvent) + { + mOnEvent += onEvent; + return new CustomUnRegister(() => { UnRegister(onEvent); }); + } + + public void UnRegister(Action onEvent) + { + mOnEvent -= onEvent; + } + + public void Trigger(T t, K k, S s) + { + mOnEvent?.Invoke(t, k, s); + } + } + + public class EasyEventSystems + { + private static EasyEventSystems _mGlobalEventSystems = new EasyEventSystems(); + + public static T Get() where T : IEasyEvent + { + return _mGlobalEventSystems.GetEvent(); + } + + + public static void Register() where T : IEasyEvent, new() + { + _mGlobalEventSystems.AddEvent(); + } + + private Dictionary mTypeEvents = new Dictionary(); + + public void AddEvent() where T : IEasyEvent, new() + { + mTypeEvents.Add(typeof(T), new T()); + } + + public T GetEvent() where T : IEasyEvent + { + IEasyEvent e; + + if (mTypeEvents.TryGetValue(typeof(T), out e)) + { + return (T) e; + } + + return default; + } + + public T GetOrAddEvent() where T : IEasyEvent, new() + { + var eType = typeof(T); + if (mTypeEvents.TryGetValue(eType, out var e)) + { + return (T) e; + } + + var t = new T(); + mTypeEvents.Add(eType, t); + return t; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs.meta new file mode 100644 index 0000000..f22960a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EasyEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e33d19dd11204fbe87eb16c6bc9b2621 +timeCreated: 1658655004 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs new file mode 100644 index 0000000..e76912e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs @@ -0,0 +1,221 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + + + public class EnumEventSystem + { + public static readonly EnumEventSystem Global = new EnumEventSystem(); + + private readonly Dictionary mEvents = new Dictionary(50); + + public EnumEventSystem(){} + + #region 功能函数 + + public IUnRegister Register(T key, Action onEvent)where T : IConvertible + { + + var kv =$"{key.ToString()}"; + if (mEvents.TryGetValue(kv, out var e)) + { + + var easyEvent = e.As(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent)where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}"; + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent)where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}_{typeof(T2).Name}"; + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}_{typeof(T2).Name}_{typeof(T3).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv, easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(T key, Action onEvent) where T : IConvertible + { + var kv =$"{key.ToString()}_objects"; + + if (mEvents.TryGetValue(kv, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(kv, easyEvent); + return easyEvent.Register(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv = key.ToString(); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}_{typeof(T2).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}_{typeof(T2).Name}_{typeof(T3).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegister(T key, Action onEvent) where T : IConvertible + { + var kv =$"{key.ToString()}_objects"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>()?.UnRegister(onEvent); + } + } + public void UnRegisterAll() + { + mEvents.Clear(); + } + + public void Send(T key) where T : IConvertible + { + var kv = key.ToString(); + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As().Trigger(); + } + else + { + Debug.LogError($"UnityEvo没有找到对应的事件:{kv}"); + } + } + public void Send(T key, T1 t1) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(t1); + } + else + { + Debug.LogError($"UnityEvo没有找到对应的事件:{kv}"); + } + } + public void Send(T key, T1 t1,T2 t2) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}_{typeof(T2).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(t1,t2); + } + else + { + Debug.LogError($"UnityEvo没有找到对应的事件:{kv}"); + } + } + public void Send(T key, T1 t1,T2 t2 ,T3 t3) where T : IConvertible + { + var kv =$"{key.ToString()}_{typeof(T1).Name}_{typeof(T2).Name}_{typeof(T3).Name}"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(t1,t2,t3); + } + else + { + Debug.LogError($"UnityEvo没有找到对应的事件:{kv}"); + } + } + public void Send(T key, params object[] args) where T : IConvertible + { + var kv =$"{key.ToString()}_objects"; + + if (mEvents.TryGetValue(kv, out var e)) + { + e.As>().Trigger(kv,args); + } + else + { + Debug.LogError($"UnityEvo没有找到对应的事件:{kv}"); + } + } + + #endregion + + public void Dispose() + { + mEvents.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs.meta new file mode 100644 index 0000000..bbcbea0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/EnumEventSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0f9c387bd15b741b2a7451be23c992ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs new file mode 100644 index 0000000..cc6eecc --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + + public class TypeEventSystem + { + private readonly EasyEventSystems _mEventSystems = new EasyEventSystems(); + + + public static readonly TypeEventSystem Global = new TypeEventSystem(); + + public void Send() where T : new() + { + _mEventSystems.GetEvent>()?.Trigger(new T()); + } + + public void Send(T e) + { + _mEventSystems.GetEvent>()?.Trigger(e); + } + + public IUnRegister Register(Action onEvent) + { + var e = _mEventSystems.GetOrAddEvent>(); + return e.Register(onEvent); + } + + public void UnRegister(Action onEvent) + { + var e = _mEventSystems.GetEvent>(); + if (e != null) + { + e.UnRegister(onEvent); + } + } + } + + public interface IOnEvent + { + void OnEvent(T e); + } + + public static class OnGlobalEventExtension + { + public static IUnRegister RegisterEvent(this IOnEvent self) where T : struct + { + return TypeEventSystem.Global.Register(self.OnEvent); + } + + public static void UnRegisterEvent(this IOnEvent self) where T : struct + { + TypeEventSystem.Global.UnRegister(self.OnEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs.meta new file mode 100644 index 0000000..e407536 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/ITypeEventSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 228453eae0804759b0fd585f7169789c +timeCreated: 1625121334 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs new file mode 100644 index 0000000..bbffce3 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; + +namespace Stary.Evo +{ + [Obsolete("推荐使用 EnumEventSystem",false)] + public class StringEventSystem + { + public static readonly StringEventSystem Global = new StringEventSystem(); + + private Dictionary mEvents = new Dictionary(); + + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent(); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public IUnRegister Register(string key, Action onEvent) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As >(); + return easyEvent.Register(onEvent); + } + else + { + var easyEvent = new EasyEvent (); + mEvents.Add(key,easyEvent); + return easyEvent.Register(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void UnRegister(string key, Action onEvent) + { + + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.UnRegister(onEvent); + } + } + public void Send(string key) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As(); + easyEvent?.Trigger(); + } + } + public void Send(string key, T data) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data); + } + } + public void Send(string key, T1 data1, T2 data2) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data1,data2); + } + } + public void Send(string key, T1 data1, T2 data2, T3 data3) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data1,data2,data3); + } + } + public void Send(string key, object[] data) + { + if (mEvents.TryGetValue(key, out var e)) + { + var easyEvent = e.As>(); + easyEvent?.Trigger(data); + } + } + public void Dispose() + { + mEvents.Clear(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs.meta new file mode 100644 index 0000000..99e3863 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventSystem/StringEventSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8502c9eab24d488c950d3eacbfc584b1 +timeCreated: 1649307359 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger.meta new file mode 100644 index 0000000..a80723d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 64db9a81348a42b8947c551059b8606e +timeCreated: 1658665668 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono.meta new file mode 100644 index 0000000..abc696a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0989f6c357dd66c4e99d135d7f605367 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs new file mode 100644 index 0000000..d5f8e27 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs @@ -0,0 +1,32 @@ +using System; +using UnityEngine; +using Stary.Evo; + +namespace Stary.Evo +{ + public class OnBecameInvisibleEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnBecameInvisibleEvent = new EasyEvent(); + + private void OnBecameInvisible() + { + OnBecameInvisibleEvent.Trigger(); + } + } + + public static class OnBecameInvisibleEventTriggerExtension + { + public static IUnRegister OnBecameInvisibleEvent(this T self, Action onBecameInvisible) + where T : Component + { + return self.GetOrAddComponent().OnBecameInvisibleEvent + .Register(onBecameInvisible); + } + + public static IUnRegister OnBecameInvisibleEvent(this GameObject self, Action onBecameInvisible) + { + return self.GetOrAddComponent().OnBecameInvisibleEvent + .Register(onBecameInvisible); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs.meta new file mode 100644 index 0000000..68131c4 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameInvisibleEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 82df3683f4d240e48bbb63f36a0eaf10 +timeCreated: 1693460492 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs new file mode 100644 index 0000000..b504a6a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs @@ -0,0 +1,31 @@ +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnBecameVisibleEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnBecameVisibleEvent = new EasyEvent(); + + private void OnBecameVisible() + { + OnBecameVisibleEvent.Trigger(); + } + } + + public static class OnBecameVisibleEventTriggerExtension + { + public static IUnRegister OnBecameVisibleEvent(this T self, Action onBecameVisible) + where T : Component + { + return self.GetOrAddComponent().OnBecameVisibleEvent + .Register(onBecameVisible); + } + + public static IUnRegister OnBecameVisibleEvent(this GameObject self, Action onBecameVisible) + { + return self.GetOrAddComponent().OnBecameVisibleEvent + .Register(onBecameVisible); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs.meta new file mode 100644 index 0000000..36adb1a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Mono/OnBecameVisibleEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d66e5459cb1f420c81fbe74291ee9f24 +timeCreated: 1693460551 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics.meta new file mode 100644 index 0000000..de9d876 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8977daa3a9c64e25a157230677908ea9 +timeCreated: 1684917953 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs new file mode 100644 index 0000000..bb4ae35 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionEnter2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionEnter2DEvent = new EasyEvent(); + private void OnCollisionEnter2D(Collision2D col) + { + OnCollisionEnter2DEvent.Trigger(col); + } + } + + public static class OnCollisionEnter2DEventTriggerExtension + { + public static IUnRegister OnCollisionEnter2DEvent(this T self, Action onCollisionEnter2D) + where T : Component + { + return self.GetOrAddComponent().OnCollisionEnter2DEvent + .Register(onCollisionEnter2D); + } + + public static IUnRegister OnCollisionEnter2DEvent(this GameObject self, Action onCollisionEnter2D) + { + return self.GetOrAddComponent().OnCollisionEnter2DEvent + .Register(onCollisionEnter2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs.meta new file mode 100644 index 0000000..0483a75 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnter2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: edcab69f84914ba59bef80b1bedf8c47 +timeCreated: 1671428212 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs new file mode 100644 index 0000000..fccd036 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs @@ -0,0 +1,33 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionEnterEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionEnterEvent = new EasyEvent(); + private void OnCollisionEnter(Collision col) + { + OnCollisionEnterEvent.Trigger(col); + } + + + } + + public static class OnCollisionEnterEventTriggerExtension + { + public static IUnRegister OnCollisionEnterEvent(this T self, Action onCollisionEnter) + where T : Component + { + return self.GetOrAddComponent().OnCollisionEnterEvent + .Register(onCollisionEnter); + } + + public static IUnRegister OnCollisionEnterEvent(this GameObject self, Action onCollisionEnter) + { + return self.GetOrAddComponent().OnCollisionEnterEvent + .Register(onCollisionEnter); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs.meta new file mode 100644 index 0000000..127115e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionEnterEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 82d00be1a2cb39144b87de1036c4e048 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs new file mode 100644 index 0000000..123b63b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionExit2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionExit2DEvent = new EasyEvent(); + private void OnCollisionExit2D(Collision2D col) + { + OnCollisionExit2DEvent.Trigger(col); + } + } + + public static class OnCollisionExit2DEventTriggerExtension + { + public static IUnRegister OnCollisionExit2DEvent(this T self, Action onCollisionExit2D) + where T : Component + { + return self.GetOrAddComponent().OnCollisionExit2DEvent + .Register(onCollisionExit2D); + } + + public static IUnRegister OnCollisionExit2DEvent(this GameObject self, Action onCollisionExit2D) + { + return self.GetOrAddComponent().OnCollisionExit2DEvent + .Register(onCollisionExit2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs.meta new file mode 100644 index 0000000..3b889e3 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExit2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8928ffac271742d0a2b772430abd4dd3 +timeCreated: 1671428509 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs new file mode 100644 index 0000000..b1bf309 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionExitEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionExitEvent = new EasyEvent(); + private void OnCollisionExit(Collision col) + { + OnCollisionExitEvent.Trigger(col); + } + } + + public static class OnCollisionExitEventTriggerExtension + { + public static IUnRegister OnCollisionExitEvent(this T self, Action onCollisionExit) + where T : Component + { + return self.GetOrAddComponent().OnCollisionExitEvent + .Register(onCollisionExit); + } + + public static IUnRegister OnCollisionExitEvent(this GameObject self, Action onCollisionExit) + { + return self.GetOrAddComponent().OnCollisionExitEvent + .Register(onCollisionExit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs.meta new file mode 100644 index 0000000..93d17ed --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionExitEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 190fce482f5f92842a9fb5710d7973fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs new file mode 100644 index 0000000..8a0981f --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionStay2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionStay2DEvent = new EasyEvent(); + private void OnCollisionStay2D(Collision2D col) + { + OnCollisionStay2DEvent.Trigger(col); + } + } + + public static class OnCollisionStay2DEventTriggerExtension + { + public static IUnRegister OnCollisionStay2DEvent(this T self, Action onCollisionStay2D) + where T : Component + { + return self.GetOrAddComponent().OnCollisionStay2DEvent + .Register(onCollisionStay2D); + } + + public static IUnRegister OnCollisionStay2DEvent(this GameObject self, Action onCollisionStay2D) + { + return self.GetOrAddComponent().OnCollisionStay2DEvent + .Register(onCollisionStay2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs.meta new file mode 100644 index 0000000..f074bd5 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStay2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 43a766fa65dd42f5ae6cd849163e6a82 +timeCreated: 1671428443 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs new file mode 100644 index 0000000..d8f8256 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnCollisionStayEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnCollisionStayEvent = new EasyEvent(); + private void OnCollisionStay(Collision col) + { + OnCollisionStayEvent.Trigger(col); + } + } + + public static class OnCollisionStayEventTriggerExtension + { + public static IUnRegister OnCollisionStayEvent(this T self, Action onCollisionStay) + where T : Component + { + return self.GetOrAddComponent().OnCollisionStayEvent + .Register(onCollisionStay); + } + + public static IUnRegister OnCollisionStayEvent(this GameObject self, Action onCollisionStay) + { + return self.GetOrAddComponent().OnCollisionStayEvent + .Register(onCollisionStay); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs.meta new file mode 100644 index 0000000..43d3e42 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnCollisionStayEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 272e5a88646c2eb41b8ee03a717c5adf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs new file mode 100644 index 0000000..3d88951 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerEnter2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerEnter2DEvent = new EasyEvent(); + private void OnTriggerEnter2D(Collider2D collider) + { + OnTriggerEnter2DEvent.Trigger(collider); + } + } + + public static class OnTriggerEnter2DEventTriggerExtension + { + public static IUnRegister OnTriggerEnter2DEvent(this T self, Action onTriggerEnter2D) + where T : Component + { + return self.GetOrAddComponent().OnTriggerEnter2DEvent + .Register(onTriggerEnter2D); + } + + public static IUnRegister OnTriggerEnter2DEvent(this GameObject self, Action onTriggerEnter2D) + { + return self.GetOrAddComponent().OnTriggerEnter2DEvent + .Register(onTriggerEnter2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs.meta new file mode 100644 index 0000000..00665ee --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnter2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 476bf1e8119b443fac10813bb49f3598 +timeCreated: 1671428580 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs new file mode 100644 index 0000000..0d92edb --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs @@ -0,0 +1,30 @@ +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerEnterEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerEnterEvent = new EasyEvent(); + private void OnTriggerEnter(Collider collider) + { + OnTriggerEnterEvent.Trigger(collider); + } + } + + public static class OnTriggerEnterEventTriggerExtension + { + public static IUnRegister OnTriggerEnterEvent(this T self, Action onTriggerEnter) + where T : Component + { + return self.GetOrAddComponent().OnTriggerEnterEvent + .Register(onTriggerEnter); + } + + public static IUnRegister OnTriggerEnterEvent(this GameObject self, Action onTriggerEnter) + { + return self.GetOrAddComponent().OnTriggerEnterEvent + .Register(onTriggerEnter); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs.meta new file mode 100644 index 0000000..264cb20 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerEnterEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bd1f6102e00b4c94c92918df44a8568e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs new file mode 100644 index 0000000..e47dbe0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerExit2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerExit2DEvent = new EasyEvent(); + private void OnTriggerExit2D(Collider2D collider) + { + OnTriggerExit2DEvent.Trigger(collider); + } + } + + public static class OnTriggerExit2DEventTriggerExtension + { + public static IUnRegister OnTriggerExit2DEvent(this T self, Action onTriggerExit2D) + where T : Component + { + return self.GetOrAddComponent().OnTriggerExit2DEvent + .Register(onTriggerExit2D); + } + + public static IUnRegister OnTriggerExit2DEvent(this GameObject self, Action onTriggerExit2D) + { + return self.GetOrAddComponent().OnTriggerExit2DEvent + .Register(onTriggerExit2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs.meta new file mode 100644 index 0000000..c77fa0a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExit2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a85117eed9334b2d9bf7cf743b10d7ce +timeCreated: 1671428822 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs new file mode 100644 index 0000000..e4fa802 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerExitEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerExitEvent = new EasyEvent(); + private void OnTriggerExit(Collider collider) + { + OnTriggerExitEvent.Trigger(collider); + } + } + + public static class OnTriggerExitEventTriggerExtension + { + public static IUnRegister OnTriggerExitEvent(this T self, Action onTriggerExit) + where T : Component + { + return self.GetOrAddComponent().OnTriggerExitEvent + .Register(onTriggerExit); + } + + public static IUnRegister OnTriggerExitEvent(this GameObject self, Action onTriggerExit) + { + return self.GetOrAddComponent().OnTriggerExitEvent + .Register(onTriggerExit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs.meta new file mode 100644 index 0000000..a4c93ff --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerExitEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 225a25d5b53dfe14fb4193eeb6c96f1e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs new file mode 100644 index 0000000..06bb780 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerStay2DEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerStay2DEvent = new EasyEvent(); + private void OnTriggerStay2D(Collider2D collider) + { + OnTriggerStay2DEvent.Trigger(collider); + } + } + + public static class OnTriggerStay2DEventTriggerExtension + { + public static IUnRegister OnTriggerStay2DEvent(this T self, Action onTriggerStay2D) + where T : Component + { + return self.GetOrAddComponent().OnTriggerStay2DEvent + .Register(onTriggerStay2D); + } + + public static IUnRegister OnTriggerStay2DEvent(this GameObject self, Action onTriggerStay2D) + { + return self.GetOrAddComponent().OnTriggerStay2DEvent + .Register(onTriggerStay2D); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs.meta new file mode 100644 index 0000000..2e96fca --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStay2DEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 33cc7e2db07b4904b50f6b37f2d4abf1 +timeCreated: 1671428742 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs new file mode 100644 index 0000000..4fe1fd3 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ + public class OnTriggerStayEventTrigger : MonoBehaviour + { + public readonly EasyEvent OnTriggerStayEvent = new EasyEvent(); + private void OnTriggerStay(Collider collider) + { + OnTriggerStayEvent.Trigger(collider); + } + } + + public static class OnTriggerStayEventTriggerExtension + { + public static IUnRegister OnTriggerStayEvent(this T self, Action onTriggerStay) + where T : Component + { + return self.GetOrAddComponent().OnTriggerStayEvent + .Register(onTriggerStay); + } + + public static IUnRegister OnTriggerStayEvent(this GameObject self, Action onTriggerStay) + { + return self.GetOrAddComponent().OnTriggerStayEvent + .Register(onTriggerStay); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs.meta new file mode 100644 index 0000000..608e2f9 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/Physics/OnTriggerStayEventTrigger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41af1f7985cb62043bea03004f786319 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI.meta new file mode 100644 index 0000000..74cdf0c --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 01eca79e7ef44fd69a8b616f1de7f765 +timeCreated: 1684917968 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs new file mode 100644 index 0000000..4aca5e0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnBeginDragEventTrigger: MonoBehaviour, IBeginDragHandler + { + public readonly EasyEvent OnBeginDragEvent = new EasyEvent(); + + public void OnBeginDrag(PointerEventData eventData) + { + OnBeginDragEvent.Trigger(eventData); + + } + } + + public static class OnBeginDragEventTriggerExtension + { + public static IUnRegister OnBeginDragEvent(this T self, Action onBeganDrag) + where T : Component + { + return self.GetOrAddComponent().OnBeginDragEvent.Register(onBeganDrag); + } + + public static IUnRegister OnBeginDragEvent(this GameObject self, Action onBeganDrag) + { + return self.GetOrAddComponent().OnBeginDragEvent.Register(onBeganDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs.meta new file mode 100644 index 0000000..25f6437 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnBeginDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: acfd1b7010c94c9aa73d78a56664eee4 +timeCreated: 1684918507 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs new file mode 100644 index 0000000..be4b230 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnCancelEventTrigger: MonoBehaviour, ICancelHandler + { + public readonly EasyEvent OnCancelEvent = new EasyEvent(); + + public void OnCancel(BaseEventData eventData) + { + OnCancelEvent.Trigger(eventData); + + } + } + + public static class OnCancelEventTriggerExtension + { + public static IUnRegister OnCancelEvent(this T self, Action onCancel) + where T : Component + { + return self.GetOrAddComponent().OnCancelEvent.Register(onCancel); + } + + public static IUnRegister OnCancelEvent(this GameObject self, Action onCancel) + { + return self.GetOrAddComponent().OnCancelEvent.Register(onCancel); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs.meta new file mode 100644 index 0000000..1ebf61a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnCancelEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f539c36d39c14257b6ba9751d1594ef4 +timeCreated: 1684921869 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs new file mode 100644 index 0000000..1b5ff11 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDeselectEventTrigger: MonoBehaviour, IDeselectHandler + { + public readonly EasyEvent OnDeselectEvent = new EasyEvent(); + + + public void OnDeselect(BaseEventData eventData) + { + OnDeselectEvent.Trigger(eventData); + } + } + + public static class OnDeselectEventTriggerExtension + { + public static IUnRegister OnDeselectEvent(this T self, Action onDeselect) + where T : Component + { + return self.GetOrAddComponent().OnDeselectEvent.Register(onDeselect); + } + + public static IUnRegister OnDeselectEvent(this GameObject self, Action onDeselect) + { + return self.GetOrAddComponent().OnDeselectEvent.Register(onDeselect); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs.meta new file mode 100644 index 0000000..674b3c8 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDeselectEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3e53e5c7e26d40dbad3843de24f8ffde +timeCreated: 1684921854 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs new file mode 100644 index 0000000..1f07708 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDragEventTrigger: MonoBehaviour, IDragHandler + { + public readonly EasyEvent OnDragEvent = new EasyEvent(); + + public void OnDrag(PointerEventData eventData) + { + OnDragEvent.Trigger(eventData); + + } + } + + public static class OnDragEventTriggerExtension + { + public static IUnRegister OnDragEvent(this T self, Action onDrag) + where T : Component + { + return self.GetOrAddComponent().OnDragEvent.Register(onDrag); + } + + public static IUnRegister OnDragEvent(this GameObject self, Action onDrag) + { + return self.GetOrAddComponent().OnDragEvent.Register(onDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs.meta new file mode 100644 index 0000000..66d4034 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cd60a9454b464db398516f09efee052d +timeCreated: 1684918694 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs new file mode 100644 index 0000000..9c3220d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnDropEventTrigger: MonoBehaviour, IDropHandler + { + public readonly EasyEvent OnDropEvent = new EasyEvent(); + + public void OnDrop(PointerEventData eventData) + { + OnDropEvent.Trigger(eventData); + } + } + + public static class OnDropEventTriggerExtension + { + public static IUnRegister OnDropEvent(this T self, Action onDrop) + where T : Component + { + return self.GetOrAddComponent().OnDropEvent.Register(onDrop); + } + + public static IUnRegister OnDropEvent(this GameObject self, Action onDrop) + { + return self.GetOrAddComponent().OnDropEvent.Register(onDrop); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs.meta new file mode 100644 index 0000000..12cc11b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnDropEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 002c533d28c84da895167c036c559b98 +timeCreated: 1684921828 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs new file mode 100644 index 0000000..e60c0ed --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnEndDragEventTrigger: MonoBehaviour, IEndDragHandler + { + public readonly EasyEvent OnEndDragEvent = new EasyEvent(); + + public void OnEndDrag(PointerEventData eventData) + { + OnEndDragEvent.Trigger(eventData); + + } + } + + public static class OnEndDragEventTriggerExtension + { + public static IUnRegister OnEndDragEvent(this T self, Action onEndDrag) + where T : Component + { + return self.GetOrAddComponent().OnEndDragEvent.Register(onEndDrag); + } + + public static IUnRegister OnEndDragEvent(this GameObject self, Action onEndDrag) + { + return self.GetOrAddComponent().OnEndDragEvent.Register(onEndDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs.meta new file mode 100644 index 0000000..ab62a64 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnEndDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 054da3c9f71e4a48b48df7b881c318aa +timeCreated: 1684918794 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs new file mode 100644 index 0000000..07ca5ad --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnInitializePotentialDragEventTrigger: MonoBehaviour, IInitializePotentialDragHandler + { + public readonly EasyEvent OnInitializePotentialDragEvent = new EasyEvent(); + + + public void OnInitializePotentialDrag(PointerEventData eventData) + { + OnInitializePotentialDragEvent.Trigger(eventData); + } + } + + public static class OnInitializePotentialDragEventTriggerExtension + { + public static IUnRegister OnInitializePotentialDragEvent(this T self, Action onInitializePotentialDrag) + where T : Component + { + return self.GetOrAddComponent().OnInitializePotentialDragEvent.Register(onInitializePotentialDrag); + } + + public static IUnRegister OnInitializePotentialDragEvent(this GameObject self, Action onInitializePotentialDrag) + { + return self.GetOrAddComponent().OnInitializePotentialDragEvent.Register(onInitializePotentialDrag); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs.meta new file mode 100644 index 0000000..f078a43 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnInitializePotentialDragEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1468538519904eb09d28417b06011d67 +timeCreated: 1684921875 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs new file mode 100644 index 0000000..39d6a54 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnMoveEventTrigger: MonoBehaviour, IMoveHandler + { + public readonly EasyEvent OnMoveEvent = new EasyEvent(); + + public void OnMove(AxisEventData eventData) + { + OnMoveEvent.Trigger(eventData); + } + } + + public static class OnMoveEventTriggerExtension + { + public static IUnRegister OnMoveEvent(this T self, Action onMove) + where T : Component + { + return self.GetOrAddComponent().OnMoveEvent.Register(onMove); + } + + public static IUnRegister OnMoveEvent(this GameObject self, Action onMove) + { + return self.GetOrAddComponent().OnMoveEvent.Register(onMove); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs.meta new file mode 100644 index 0000000..b01b930 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnMoveEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 624f894e14aa490db08cf81024600e93 +timeCreated: 1684921859 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs new file mode 100644 index 0000000..d8ac5b4 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerClickEventTrigger : MonoBehaviour, IPointerClickHandler + { + public readonly EasyEvent OnPointerClickEvent = new EasyEvent(); + + public void OnPointerClick(PointerEventData eventData) + { + OnPointerClickEvent.Trigger(eventData); + } + } + + public static class OnPointerClickEventTriggerExtension + { + public static IUnRegister OnPointerClickEvent(this T self, Action onPointerClick) + where T : Component + { + return self.GetOrAddComponent().OnPointerClickEvent.Register(onPointerClick); + } + + public static IUnRegister OnPointerClickEvent(this GameObject self, Action onPointerClick) + { + return self.GetOrAddComponent().OnPointerClickEvent.Register(onPointerClick); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs.meta new file mode 100644 index 0000000..cf7837e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerClickEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3ae5dbb0c46a4a828719e58bcf539e09 +timeCreated: 1658665723 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs new file mode 100644 index 0000000..783d8ea --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs @@ -0,0 +1,33 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerDownEventTrigger : MonoBehaviour,IPointerDownHandler + { + public readonly EasyEvent OnPointerDownEvent = new EasyEvent(); + + public void OnPointerDown(PointerEventData eventData) + { + OnPointerDownEvent.Trigger(eventData); + } + } + + public static class OnPointerDownEventTriggerExtension + { + public static IUnRegister OnPointerDownEvent(this T self, Action onPointerDownEvent) + where T : Component + { + return self.GetOrAddComponent().OnPointerDownEvent + .Register(onPointerDownEvent); + } + + public static IUnRegister OnPointerDownEvent(this GameObject self, Action onPointerDownEvent) + { + return self.GetOrAddComponent().OnPointerDownEvent + .Register(onPointerDownEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs.meta new file mode 100644 index 0000000..bb944dc --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerDownEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7ad55473a3084b0e91aa28972b4739e0 +timeCreated: 1684917989 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs new file mode 100644 index 0000000..d85cc03 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerEnterEventTrigger : MonoBehaviour, IPointerEnterHandler + { + public readonly EasyEvent OnPointerEnterEvent = new EasyEvent(); + + public void OnPointerEnter(PointerEventData eventData) + { + OnPointerEnterEvent.Trigger(eventData); + } + } + + public static class OnPointerEnterEventTriggerExtension + { + public static IUnRegister OnPointerEnterEvent(this T self, Action onPointerEnter) + where T : Component + { + return self.GetOrAddComponent().OnPointerEnterEvent.Register(onPointerEnter); + } + + public static IUnRegister OnPointerEnterEvent(this GameObject self, Action onPointerEnter) + { + return self.GetOrAddComponent().OnPointerEnterEvent.Register(onPointerEnter); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs.meta new file mode 100644 index 0000000..6013cea --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerEnterEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: abdff8ce2d614a1898361669f649034c +timeCreated: 1684921387 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs new file mode 100644 index 0000000..eae816c --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerExitEventTrigger : MonoBehaviour, IPointerExitHandler + { + public readonly EasyEvent OnPointerExitEvent = new EasyEvent(); + + public void OnPointerExit(PointerEventData eventData) + { + OnPointerExitEvent.Trigger(eventData); + } + } + + public static class OnPointerExitEventTriggerExtension + { + public static IUnRegister OnPointerExitEvent(this T self, Action onPointerExit) + where T : Component + { + return self.GetOrAddComponent().OnPointerExitEvent.Register(onPointerExit); + } + + public static IUnRegister OnPointerExitEvent(this GameObject self, Action onPointerExit) + { + return self.GetOrAddComponent().OnPointerExitEvent.Register(onPointerExit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs.meta new file mode 100644 index 0000000..0ed7e23 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerExitEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a0b4ce9dfff1418787b11f87638a30f8 +timeCreated: 1684921704 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs new file mode 100644 index 0000000..aaabd3a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs @@ -0,0 +1,33 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnPointerUpEventTrigger : MonoBehaviour,IPointerUpHandler + { + public readonly EasyEvent OnPointerUpEvent = new EasyEvent(); + + public void OnPointerUp(PointerEventData eventData) + { + OnPointerUpEvent.Trigger(eventData); + } + } + + public static class OnPointerUpEventTriggerExtension + { + public static IUnRegister OnPointerUpEvent(this T self, Action onPointerUpEvent) + where T : Component + { + return self.GetOrAddComponent().OnPointerUpEvent + .Register(onPointerUpEvent); + } + + public static IUnRegister OnPointerUpEvent(this GameObject self, Action onPointerUpEvent) + { + return self.GetOrAddComponent().OnPointerUpEvent + .Register(onPointerUpEvent); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs.meta new file mode 100644 index 0000000..50d1f67 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnPointerUpEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4975092dfacf4edd95cf8142d6d549ca +timeCreated: 1684918304 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs new file mode 100644 index 0000000..f14788f --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnScrollEventTrigger: MonoBehaviour, IScrollHandler + { + public readonly EasyEvent OnScrollEvent = new EasyEvent(); + + public void OnScroll(PointerEventData eventData) + { + OnScrollEvent.Trigger(eventData); + } + } + + public static class OnScrollEventTriggerExtension + { + public static IUnRegister OnScrollEvent(this T self, Action onScroll) + where T : Component + { + return self.GetOrAddComponent().OnScrollEvent.Register(onScroll); + } + + public static IUnRegister OnScrollEvent(this GameObject self, Action onScroll) + { + return self.GetOrAddComponent().OnScrollEvent.Register(onScroll); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs.meta new file mode 100644 index 0000000..5a25c3b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnScrollEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a5eff617f4604eb7b6439224ffa9bffe +timeCreated: 1684921838 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs new file mode 100644 index 0000000..d65b535 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnSelectEventTrigger: MonoBehaviour, ISelectHandler + { + public readonly EasyEvent OnSelectEvent = new EasyEvent(); + + public void OnSelect(BaseEventData eventData) + { + OnSelectEvent.Trigger(eventData); + } + } + + public static class OnSelectEventTriggerTriggerExtension + { + public static IUnRegister OnSelectEvent(this T self, Action onSelect) + where T : Component + { + return self.GetOrAddComponent().OnSelectEvent.Register(onSelect); + } + + public static IUnRegister OnSelectEvent(this GameObject self, Action onSelect) + { + return self.GetOrAddComponent().OnSelectEvent.Register(onSelect); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs.meta new file mode 100644 index 0000000..854acd7 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSelectEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c1c1463405ce421b8764390fa5bb764d +timeCreated: 1684921849 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs new file mode 100644 index 0000000..4daf29c --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs @@ -0,0 +1,31 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnSubmitEventTrigger: MonoBehaviour, ISubmitHandler + { + public readonly EasyEvent OnSubmitEvent = new EasyEvent(); + + public void OnSubmit(BaseEventData eventData) + { + OnSubmitEvent.Trigger(eventData); + } + } + + public static class OnSubmitEventTriggerExtension + { + public static IUnRegister OnSubmitEvent(this T self, Action onSubmit) + where T : Component + { + return self.GetOrAddComponent().OnSubmitEvent.Register(onSubmit); + } + + public static IUnRegister OnSubmitEvent(this GameObject self, Action onSubmit) + { + return self.GetOrAddComponent().OnSubmitEvent.Register(onSubmit); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs.meta new file mode 100644 index 0000000..4351ead --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnSubmitEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b72c739ccdec4249bf698dee82a4f475 +timeCreated: 1684921864 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs new file mode 100644 index 0000000..d43e373 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs @@ -0,0 +1,32 @@ + +using System; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Stary.Evo +{ + public class OnUpdateSelectedEventTrigger: MonoBehaviour, IUpdateSelectedHandler + { + public readonly EasyEvent OnUpdateSelectedEvent = new EasyEvent(); + + + public void OnUpdateSelected(BaseEventData eventData) + { + OnUpdateSelectedEvent.Trigger(eventData); + } + } + + public static class OnUpdateSelectedEventTriggerExtension + { + public static IUnRegister OnUpdateSelectedEvent(this T self, Action onUpdateSelected) + where T : Component + { + return self.GetOrAddComponent().OnUpdateSelectedEvent.Register(onUpdateSelected); + } + + public static IUnRegister OnUpdateSelectedEvent(this GameObject self, Action onUpdateSelected) + { + return self.GetOrAddComponent().OnUpdateSelectedEvent.Register(onUpdateSelected); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs.meta new file mode 100644 index 0000000..0a824e9 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/EventTrigger/UI/OnUpdateSelectedEventTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 11b3a438de52430e8f4b435d4a095fb4 +timeCreated: 1684921844 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Example.unitypackage.meta b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Example.unitypackage.meta new file mode 100644 index 0000000..daf4943 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/EventKit/Example.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 194887e39d37cd742a57ffe4cfe1b21b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM.meta new file mode 100644 index 0000000..33044aa --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21faa0c1703071142a9c56c1b5a96cfc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultState.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultState.cs new file mode 100644 index 0000000..20df18c --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultState.cs @@ -0,0 +1,22 @@ +using Cysharp.Threading.Tasks; + +namespace Stary.Evo +{ + public class DefaultState : AbstractFSMIState + { + public DefaultState(IFsmSystem system) : base(system) + { + + } + + public override void OnEnter() + { + + } + + public override void OnExit() + { + + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultState.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultState.cs.meta new file mode 100644 index 0000000..7cc26fd --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultState.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fa9b0b9ba7a849f597744565a49bd61a +timeCreated: 1744547550 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultStateAsync.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultStateAsync.cs new file mode 100644 index 0000000..4e51ab8 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultStateAsync.cs @@ -0,0 +1,31 @@ +using Cysharp.Threading.Tasks; + +namespace Stary.Evo +{ + public class DefaultStateAsync : AbstractFSMIStateAsync + { + public DefaultStateAsync(IFsmSystemAsync system) : base(system) + { + } + + public override UniTask OnExitAsync() + { + return UniTask.CompletedTask; + } + + public override UniTask OnEnterAsync() + { + return UniTask.CompletedTask; + } + + public override UniTask OnEnterAsync(T param) + { + return UniTask.CompletedTask; + } + + public override UniTask OnEnterAsync(T1 param1, T2 param2) + { + return UniTask.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultStateAsync.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultStateAsync.cs.meta new file mode 100644 index 0000000..b7bbc7d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/DefaultStateAsync.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 220c409c3499492ca07525d7323eb17f +timeCreated: 1753696060 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIState.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIState.cs new file mode 100644 index 0000000..ae2e318 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIState.cs @@ -0,0 +1,66 @@ +using System; +using Cysharp.Threading.Tasks; +using UnityEngine; + +namespace Stary.Evo +{ + public interface FSMIState + { + IFsmSystem FsmSystem { get; } + string Name { get; } + + + //进入该状态时调用 + void OnEnter(); + + void OnEnter(object param); + + void OnEnter(T param); + + void OnEnter(T1 param1, T2 param2); + + + + //每帧调用 + void OnUpdate(); + //退出该状态时调用 + + void OnExit(); + } + + public abstract class AbstractFSMIState : FSMIState + { + public IFsmSystem FsmSystem { get; } + public string Name { get; } + + public AbstractFSMIState(IFsmSystem system) + { + FsmSystem = system; + Name = GetType().Name; + } + + public virtual void OnEnter(object param) + { + + } + + public virtual void OnEnter(T param) + { + + } + + public virtual void OnEnter(T1 param1, T2 param2) + { + + } + public abstract void OnEnter(); + + public virtual void OnUpdate() + { + // Timer += Time.deltaTime; + } + + + public abstract void OnExit(); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIState.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIState.cs.meta new file mode 100644 index 0000000..84003c9 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1dc351fc8dc35ec4ca388c24444a80a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIStateAsync.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIStateAsync.cs new file mode 100644 index 0000000..7796ef4 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIStateAsync.cs @@ -0,0 +1,64 @@ +using System; +using Cysharp.Threading.Tasks; +using UnityEngine; + +namespace Stary.Evo +{ + public interface FSMIStateAsync + { + IFsmSystemAsync FsmSystem { get; } + string Name { get; } + + + //进入该状态时调用 + UniTask OnEnterAsync(); + + UniTask OnEnterAsync(object param); + + UniTask OnEnterAsync(T param); + + UniTask OnEnterAsync(T1 param1, T2 param2); + + //每帧调用 + void OnUpdate(); + //退出该状态时调用 + + UniTask OnExitAsync(); + } + + public abstract class AbstractFSMIStateAsync : FSMIStateAsync + { + public IFsmSystemAsync FsmSystem { get; } + public string Name { get; } + + public AbstractFSMIStateAsync(IFsmSystemAsync system) + { + FsmSystem = system; + Name = GetType().Name; + } + + public virtual UniTask OnEnterAsync(object param) + { + return UniTask.CompletedTask; + } + + public virtual UniTask OnEnterAsync(T param) + { + return UniTask.CompletedTask; + } + + public virtual UniTask OnEnterAsync(T1 param1, T2 param2) + { + return UniTask.CompletedTask; + } + public abstract UniTask OnEnterAsync(); + + public virtual void OnUpdate() + { + // Timer += Time.deltaTime; + } + + + public abstract UniTask OnExitAsync(); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIStateAsync.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIStateAsync.cs.meta new file mode 100644 index 0000000..29a6774 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMIStateAsync.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 67ef9a881ef94206a5bc80eab8f8e2df +timeCreated: 1753695833 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystem.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystem.cs new file mode 100644 index 0000000..cd472dc --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystem.cs @@ -0,0 +1,136 @@ +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using UnityEngine; + +namespace Stary.Evo +{ + public interface IFsmSystem + { + FSMIState CurState { get; set; } + void AddState(FSMIState state); + void RemoveState(FSMIState state); + void SetCurState(string name); + + void SetCurState(string name, object param); + void SetCurState(string name, T param); + void SetCurState(string name, T1 param1, T2 param2); + FSMIState GetStateWithName(string name); + HashMap States { get; set; } + } + + public class FsmSystem : IFsmSystem + { + public FSMIState CurState { get; set; } + public HashMap States { get; set; } + + public FsmSystem() + { + States = new HashMap(); + AddState(new DefaultState(this)); + } + + public void AddState(FSMIState state) + { + Debug.Log(state.Name); + if (!States.ContainsKey(state.Name)) + { + States.Add(state.Name, state); + } + else + { + Debug.LogErrorFormat("States状态机容器里已存在名字为--【{0}】--的状态", state.Name.ToString()); + } + } + + public void RemoveState(FSMIState state) + { + if (States.ContainsKey(state.Name)) + { + States.Remove(state.Name); + } + else + { + Debug.LogErrorFormat("States状态机容器里不存在名字为--【{0}】--的状态", state.Name.ToString()); + } + } + + /// + /// 普通状态切换,适用于无参 + /// + /// + public async void SetCurState(string name) + { + if (CurState != null) + CurState.OnExit(); + FSMIState state = GetStateWithName(name); + CurState = state; + CurState.OnEnter(); + } + + /// + /// 异步状态切换,适用于有参 + /// + /// + /// + /// + public async void SetCurState(string name, object param) + { + if (CurState != null) + { + CurState.OnExit(); + } + + FSMIState state = GetStateWithName(name); + CurState = state; + CurState.OnEnter(param); + } + + /// + /// 异步状态切换,适用于有参 + /// + /// + /// + /// + public async void SetCurState(string name, T param) + { + if (CurState != null) + { + CurState.OnExit(); + } + + FSMIState state = GetStateWithName(name); + CurState = state; + CurState.OnEnter(param); + } + + /// + /// 异步状态切换,适用于有参 + /// + /// + /// + /// + /// + /// + public async void SetCurState(string name, T1 param1, T2 param2) + { + if (CurState != null) + { + CurState.OnExit(); + } + + FSMIState state = GetStateWithName(name); + CurState = state; + CurState.OnEnter(param1, param2); + } + + public FSMIState GetStateWithName(string name) + { + if (States.ContainsKey(name)) + { + return States[name]; + } + + return null; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystem.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystem.cs.meta new file mode 100644 index 0000000..6752dc0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 572d20e55965479cb8846f9fad4873a2 +timeCreated: 1625997700 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystemAsync.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystemAsync.cs new file mode 100644 index 0000000..99ca9b0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystemAsync.cs @@ -0,0 +1,137 @@ +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using UnityEngine; + +namespace Stary.Evo +{ + public interface IFsmSystemAsync + { + FSMIStateAsync CurState { get; set; } + void AddState(FSMIStateAsync state); + void RemoveState(FSMIStateAsync state); + UniTask SetCurState(string name); + + UniTask SetCurState(string name, object param); + UniTask SetCurState(string name, T param); + UniTask SetCurState(string name, T1 param1, T2 param2); + FSMIStateAsync GetStateWithName(string name); + HashMap States { get; set; } + } + + public class FsmSystemAsync : IFsmSystemAsync + { + public FSMIStateAsync CurState { get; set; } + public HashMap States { get; set; } + + public FsmSystemAsync() + { + States = new HashMap(); + AddState(new DefaultStateAsync(this)); + } + + public void AddState(FSMIStateAsync state) + { + Debug.Log(state.Name); + if (!States.ContainsKey(state.Name)) + { + States.Add(state.Name, state); + } + else + { + Debug.LogErrorFormat("States状态机容器里已存在名字为--【{0}】--的状态", state.Name.ToString()); + } + } + + + public void RemoveState(FSMIStateAsync state) + { + if (States.ContainsKey(state.Name)) + { + States.Remove(state.Name); + } + else + { + Debug.LogErrorFormat("States状态机容器里不存在名字为--【{0}】--的状态", state.Name.ToString()); + } + } + + /// + /// 普通状态切换,适用于无参 + /// + /// + public async UniTask SetCurState(string name) + { + if (CurState != null) + await CurState.OnExitAsync(); + FSMIStateAsync state = GetStateWithName(name); + CurState = state; + CurState.OnEnterAsync(); + } + + /// + /// 异步状态切换,适用于有参 + /// + /// + /// + /// + public async UniTask SetCurState(string name, object param) + { + if (CurState != null) + { + await CurState.OnExitAsync(); + } + + FSMIStateAsync state = GetStateWithName(name); + CurState = state; + await CurState.OnEnterAsync(param); + } + + /// + /// 异步状态切换,适用于有参 + /// + /// + /// + /// + public async UniTask SetCurState(string name, T param) + { + if (CurState != null) + { + await CurState.OnExitAsync(); + } + + FSMIStateAsync state = GetStateWithName(name); + CurState = state; + await CurState.OnEnterAsync(param); + } + + /// + /// 异步状态切换,适用于有参 + /// + /// + /// + /// + /// + /// + public async UniTask SetCurState(string name, T1 param1, T2 param2) + { + if (CurState != null) + { + await CurState.OnExitAsync(); + } + + FSMIStateAsync state = GetStateWithName(name); + CurState = state; + await CurState.OnEnterAsync(param1, param2); + } + + public FSMIStateAsync GetStateWithName(string name) + { + if (States.ContainsKey(name)) + { + return States[name]; + } + + return null; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystemAsync.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystemAsync.cs.meta new file mode 100644 index 0000000..5d7185c --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FSM/FSMISystemAsync.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e04d52ffeda84bf4a096108e88667852 +timeCreated: 1753695847 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI.meta new file mode 100644 index 0000000..4f202cd --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f099e1f5ec77994f97c7988bde11d4f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity.meta new file mode 100644 index 0000000..573936d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 84dfa4614a74466f938b3c4cfb7f63f0 +timeCreated: 1647443763 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs new file mode 100644 index 0000000..5175dac --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs @@ -0,0 +1,230 @@ +using Stary.Evo; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Object", 0)] + [APIDescriptionCN("针对 UnityEngine.Object 提供的链式扩展")] + [APIDescriptionEN("The chain extension provided by UnityEngine.Object")] + [APIExampleCode(@" +var gameObject = new GameObject(); +// +gameObject.Instantiate() + .Name(""ExtensionExample"") + .DestroySelf(); +// +gameObject.Instantiate() + .DestroySelfGracefully(); +// +gameObject.Instantiate() + .DestroySelfAfterDelay(1.0f); +// +gameObject.Instantiate() + .DestroySelfAfterDelayGracefully(1.0f); +// +gameObject + .Self(selfObj => Debug.Log(selfObj.name)) + .Name(""TestObj"") + .Self(selfObj => Debug.Log(selfObj.name)) + .Name(""ExtensionExample"") + .DontDestroyOnLoad(); +")] +#endif + public static class UnityEngineObjectExtension + { +#if UNITY_EDITOR + // v1 No.37 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Object) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Object) extension")] + [APIExampleCode(@" +prefab.Instantiate(); +")] +#endif + public static T Instantiate(this T selfObj) where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj); + } +#if UNITY_EDITOR + // v1 No.38 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Object,Vector3,Quaternion) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Object,Vector3,Quaternion) extension")] + [APIExampleCode(@" +prefab.Instantiate(Vector3.zero,Quaternion.identity); +")] +#endif + public static T Instantiate(this T selfObj, Vector3 position, Quaternion rotation) + where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, position, rotation); + } + +#if UNITY_EDITOR + // v1 No.39 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Object,Vector3,Quaternion,Transform parent) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Object,Vector3,Quaternion,Transform parent) extension")] + [APIExampleCode(@" +prefab.Instantiate(Vector3.zero,Quaternion.identity,transformRoot); +")] +#endif + public static T Instantiate( + this T selfObj, + Vector3 position, + Quaternion rotation, + Transform parent) + where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, position, rotation, parent); + } + +#if UNITY_EDITOR + // v1 No.40 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Transform parent,bool worldPositionStays) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Transform parent,bool worldPositionStays) extension")] + [APIExampleCode(@" +prefab.Instantiate(transformRoot,true); +")] +#endif + public static T InstantiateWithParent(this T selfObj, Transform parent, bool worldPositionStays) + where T : UnityEngine.Object + { + return (T)UnityEngine.Object.Instantiate((UnityEngine.Object)selfObj, parent, worldPositionStays); + } + + public static T InstantiateWithParent(this T selfObj, Component parent, bool worldPositionStays) + where T : UnityEngine.Object + { + return (T)UnityEngine.Object.Instantiate((UnityEngine.Object)selfObj, parent.transform, worldPositionStays); + } +#if UNITY_EDITOR + // v1 No.41 + [MethodAPI] + [APIDescriptionCN("Object.Instantiate(Transform parent) 的简单链式封装")] + [APIDescriptionEN("Object.Instantiate(Transform parent) extension")] + [APIExampleCode(@" +prefab.Instantiate(transformRoot); +")] +#endif + public static T InstantiateWithParent(this T selfObj, Transform parent) where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, parent, false); + } + + public static T InstantiateWithParent(this T selfObj, Component parent) where T : UnityEngine.Object + { + return UnityEngine.Object.Instantiate(selfObj, parent.transform, false); + } + + +#if UNITY_EDITOR + // v1 No.42 + [MethodAPI] + [APIDescriptionCN("设置名字")] + [APIDescriptionEN("set Object's name")] + [APIExampleCode(@" +scriptableObject.Name(""LevelData""); +Debug.Log(scriptableObject.name); +// LevelData +")] +#endif + public static T Name(this T selfObj, string name) where T : UnityEngine.Object + { + selfObj.name = name; + return selfObj; + } + + +#if UNITY_EDITOR + // v1 No.43 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object) extension")] + [APIExampleCode(@" +new GameObject().DestroySelf() +")] +#endif + public static void DestroySelf(this T selfObj) where T : UnityEngine.Object + { + UnityEngine.Object.Destroy(selfObj); + } + +#if UNITY_EDITOR + // v1 No.44 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object) extension")] + [APIExampleCode(@" +GameObject gameObj = null; +gameObj.DestroySelfGracefully(); +// not throw null exception +// 这样写不会报异常(但是不好调试) +")] +#endif + public static T DestroySelfGracefully(this T selfObj) where T : UnityEngine.Object + { + if (selfObj) + { + UnityEngine.Object.Destroy(selfObj); + } + + return selfObj; + } + + +#if UNITY_EDITOR + // v1 No.45 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object,float) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object,float) extension")] + [APIExampleCode(@" +new GameObject().DestroySelfAfterDelay(5); +")] +#endif + public static T DestroySelfAfterDelay(this T selfObj, float afterDelay) where T : UnityEngine.Object + { + UnityEngine.Object.Destroy(selfObj, afterDelay); + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.46 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(Object,float) 简单链式封装")] + [APIDescriptionEN("Object.Destroy(Object,float) extension")] + [APIExampleCode(@" +GameObject gameObj = null; +gameObj.DestroySelfAfterDelayGracefully(5); +// not throw exception +// 不会报异常 +")] +#endif + public static T DestroySelfAfterDelayGracefully(this T selfObj, float delay) where T : UnityEngine.Object + { + if (selfObj) + { + UnityEngine.Object.Destroy(selfObj, delay); + } + + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.47 + [MethodAPI] + [APIDescriptionCN("Object.DontDestroyOnLoad 简单链式封装")] + [APIDescriptionEN("Object.DontDestroyOnLoad extension")] + [APIExampleCode(@" +new GameObject().DontDestroyOnLoad(); +")] +#endif + public static T DontDestroyOnLoad(this T selfObj) where T : UnityEngine.Object + { + UnityEngine.Object.DontDestroyOnLoad(selfObj); + return selfObj; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs.meta new file mode 100644 index 0000000..03f4e74 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/0.UnityEngineObjectExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5f82c097d6fc40e3ba52585f53920178 +timeCreated: 1647487579 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs new file mode 100644 index 0000000..764fc6d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs @@ -0,0 +1,334 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.GameObject", 1)] + [APIDescriptionCN("针对 UnityEngine.GameObject 提供的链式扩展")] + [APIDescriptionEN("The chain extension provided by UnityEngine.Object.")] + [APIExampleCode(@" +var gameObject = new GameObject(); +var transform = gameObject.transform; +var selfScript = gameObject.AddComponent(); +var boxCollider = gameObject.AddComponent(); +// +gameObject.Show(); // gameObject.SetActive(true) +selfScript.Show(); // this.gameObject.SetActive(true) +boxCollider.Show(); // boxCollider.gameObject.SetActive(true) +gameObject.transform.Show(); // transform.gameObject.SetActive(true) +// +gameObject.Hide(); // gameObject.SetActive(false) +selfScript.Hide(); // this.gameObject.SetActive(false) +boxCollider.Hide(); // boxCollider.gameObject.SetActive(false) +transform.Hide(); // transform.gameObject.SetActive(false) +// +selfScript.DestroyGameObj(); +boxCollider.DestroyGameObj(); +]transform.DestroyGameObj(); +// +selfScript.DestroyGameObjGracefully(); +boxCollider.DestroyGameObjGracefully(); +transform.DestroyGameObjGracefully(); +// +selfScript.DestroyGameObjAfterDelay(1.0f); +boxCollider.DestroyGameObjAfterDelay(1.0f); +transform.DestroyGameObjAfterDelay(1.0f); +// +selfScript.DestroyGameObjAfterDelayGracefully(1.0f); +boxCollider.DestroyGameObjAfterDelayGracefully(1.0f); +transform.DestroyGameObjAfterDelayGracefully(1.0f); +// +gameObject.Layer(0); +selfScript.Layer(0); +boxCollider.Layer(0); +transform.Layer(0); +// +gameObject.Layer(""Default""); +selfScript.Layer(""Default""); +boxCollider.Layer(""Default""); +transform.Layer(""Default""); +")] +#endif + public static class UnityEngineGameObjectExtension + { +#if UNITY_EDITOR + // v1 No.48 + [MethodAPI] + [APIDescriptionCN("gameObject.SetActive(true)")] + [APIDescriptionEN("gameObject.SetActive(true)")] + [APIExampleCode(@" +new GameObject().Show(); +")] +#endif + public static GameObject Show(this GameObject selfObj) + { + selfObj.SetActive(true); + return selfObj; + } +#if UNITY_EDITOR + // v1 No.49 + [MethodAPI] + [APIDescriptionCN("script.gameObject.SetActive(true)")] + [APIDescriptionEN("script.gameObject.SetActive(true)")] + [APIExampleCode(@" +GetComponent().Show(); +")] +#endif + public static T Show(this T selfComponent) where T : Component + { + selfComponent.gameObject.Show(); + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.50 + [MethodAPI] + [APIDescriptionCN("gameObject.SetActive(false)")] + [APIDescriptionEN("gameObject.SetActive(false)")] + [APIExampleCode(@" +gameObject.Hide(); +")] +#endif + public static GameObject Hide(this GameObject selfObj) + { + selfObj.SetActive(false); + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.51 + [MethodAPI] + [APIDescriptionCN("myScript.gameObject.SetActive(false)")] + [APIDescriptionEN("myScript.gameObject.SetActive(false)")] + [APIExampleCode(@" +GetComponent().Hide(); +")] +#endif + public static T Hide(this T selfComponent) where T : Component + { + selfComponent.gameObject.Hide(); + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.52 + [MethodAPI] + [APIDescriptionCN("Destroy(myScript.gameObject)")] + [APIDescriptionEN("Destroy(myScript.gameObject)")] + [APIExampleCode(@" +myScript.DestroyGameObj(); +")] +#endif + public static void DestroyGameObj(this T selfBehaviour) where T : Component + { + selfBehaviour.gameObject.DestroySelf(); + } + + +#if UNITY_EDITOR + // v1 No.53 + [MethodAPI] + [APIDescriptionCN("if (myScript) Destroy(myScript.gameObject)")] + [APIDescriptionEN("if (myScript) Destroy(myScript.gameObject)")] + [APIExampleCode(@" +myScript.DestroyGameObjGracefully(); +")] +#endif + public static void DestroyGameObjGracefully(this T selfBehaviour) where T : Component + { + if (selfBehaviour && selfBehaviour.gameObject) + { + selfBehaviour.gameObject.DestroySelfGracefully(); + } + } + +#if UNITY_EDITOR + // v1 No.54 + [MethodAPI] + [APIDescriptionCN("Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIDescriptionEN("Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIExampleCode(@" +myScript.DestroyGameObjAfterDelay(5); +")] +#endif + public static T DestroyGameObjAfterDelay(this T selfBehaviour, float delay) where T : Component + { + selfBehaviour.gameObject.DestroySelfAfterDelay(delay); + return selfBehaviour; + } + +#if UNITY_EDITOR + // v1 No.55 + [MethodAPI] + [APIDescriptionCN("if (myScript && myScript.gameObject) Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIDescriptionEN("if (myScript && myScript.gameObject) Object.Destroy(myScript.gameObject,delaySeconds)")] + [APIExampleCode(@" +myScript.DestroyGameObjAfterDelayGracefully(5); +")] +#endif + public static T DestroyGameObjAfterDelayGracefully(this T selfBehaviour, float delay) where T : Component + { + if (selfBehaviour && selfBehaviour.gameObject) + { + selfBehaviour.gameObject.DestroySelfAfterDelay(delay); + } + + return selfBehaviour; + } + + +#if UNITY_EDITOR + // v1 No.56 + [MethodAPI] + [APIDescriptionCN("gameObject.layer = layer")] + [APIDescriptionEN("gameObject.layer = layer")] + [APIExampleCode(@" +new GameObject().Layer(0); +")] +#endif + public static GameObject Layer(this GameObject selfObj, int layer) + { + selfObj.layer = layer; + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.57 + [MethodAPI] + [APIDescriptionCN("component.gameObject.layer = layer")] + [APIDescriptionEN("component.gameObject.layer = layer")] + [APIExampleCode(@" +rigidbody2D.Layer(0); +")] +#endif + public static T Layer(this T selfComponent, int layer) where T : Component + { + selfComponent.gameObject.layer = layer; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.58 + [MethodAPI] + [APIDescriptionCN("gameObj.layer = LayerMask.NameToLayer(layerName)")] + [APIDescriptionEN("gameObj.layer = LayerMask.NameToLayer(layerName)")] + [APIExampleCode(@" +new GameObject().Layer(""Default""); +")] +#endif + + public static GameObject Layer(this GameObject selfObj, string layerName) + { + selfObj.layer = LayerMask.NameToLayer(layerName); + return selfObj; + } + +#if UNITY_EDITOR + // v1 No.59 + [MethodAPI] + [APIDescriptionCN("component.gameObject.layer = LayerMask.NameToLayer(layerName)")] + [APIDescriptionEN("component.gameObject.layer = LayerMask.NameToLayer(layerName)")] + [APIExampleCode(@" +spriteRenderer.Layer(""Default""); +")] +#endif + public static T Layer(this T selfComponent, string layerName) where T : Component + { + selfComponent.gameObject.layer = LayerMask.NameToLayer(layerName); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.60 + [MethodAPI] + [APIDescriptionCN("layerMask 中的层级是否包含 gameObj 所在的层级")] + [APIDescriptionEN("Whether the layer in layerMask contains the same layer as gameObj")] + [APIExampleCode(@" +gameObj.IsInLayerMask(layerMask); +")] +#endif + public static bool IsInLayerMask(this GameObject selfObj, LayerMask layerMask) + { + return LayerMaskUtility.IsInLayerMask(selfObj, layerMask); + } + +#if UNITY_EDITOR + // v1 No.61 + [MethodAPI] + [APIDescriptionCN("layerMask 中的层级是否包含 component.gameObject 所在的层级")] + [APIDescriptionEN("Whether the layer in layerMask contains the same layer as component.gameObject")] + [APIExampleCode(@" +spriteRenderer.IsInLayerMask(layerMask); +")] +#endif + public static bool IsInLayerMask(this T selfComponent, LayerMask layerMask) where T : Component + { + return LayerMaskUtility.IsInLayerMask(selfComponent.gameObject, layerMask); + } + + +#if UNITY_EDITOR + // v1 No.62 + [MethodAPI] + [APIDescriptionCN("获取组件,没有则添加再返回")] + [APIDescriptionEN("Get component, add and return if not")] + [APIExampleCode(@" +gameObj.GetOrAddComponent(); +")] +#endif + public static T GetOrAddComponent(this GameObject self) where T : Component + { + var comp = self.gameObject.GetComponent(); + return comp ? comp : self.gameObject.AddComponent(); + } + +#if UNITY_EDITOR + // v1 No.63 + [MethodAPI] + [APIDescriptionCN("获取组件,没有则添加再返回")] + [APIDescriptionEN("Get component, add and return if not")] + [APIExampleCode(@" +component.GetOrAddComponent(); +")] +#endif + public static T GetOrAddComponent(this Component component) where T : Component + { + return component.gameObject.GetOrAddComponent(); + } + +#if UNITY_EDITOR + // v1 No.64 + [MethodAPI] + [APIDescriptionCN("获取组件,没有则添加再返回")] + [APIDescriptionEN("Get component, add and return if not")] + [APIExampleCode(@" +gameObj.GetOrAddComponent(typeof(SpriteRenderer)); +")] +#endif + public static Component GetOrAddComponent(this GameObject self, Type type) + { + var component = self.gameObject.GetComponent(type); + return component ? component : self.gameObject.AddComponent(type); + } + } + + public static class LayerMaskUtility + { + public static bool IsInLayerMask(int layer, LayerMask layerMask) + { + var objLayerMask = 1 << layer; + return (layerMask.value & objLayerMask) == objLayerMask; + } + + public static bool IsInLayerMask(GameObject gameObj, LayerMask layerMask) + { + // 根据Layer数值进行移位获得用于运算的Mask值 + var objLayerMask = 1 << gameObj.layer; + return (layerMask.value & objLayerMask) == objLayerMask; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs.meta new file mode 100644 index 0000000..fc8dfd6 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/1.UnityEngineGameObjectExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 36146f65e25b4ec79d3030f3babbc6cc +timeCreated: 1647490642 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs new file mode 100644 index 0000000..377a68f --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs @@ -0,0 +1,1743 @@ + +using System; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Transform", 2)] + [APIDescriptionCN("针对 UnityEngine.GameObject 提供的链式扩展")] + [APIDescriptionEN("The chain extension provided by UnityEngine.Object.")] + [APIExampleCode(@" +var selfScript = new GameObject().AddComponent(); +var transform = selfScript.transform; + +transform + .Parent(null) + .LocalIdentity() + .LocalPositionIdentity() + .LocalRotationIdentity() + .LocalScaleIdentity() + .LocalPosition(Vector3.zero) + .LocalPosition(0, 0, 0) + .LocalPosition(0, 0) + .LocalPositionX(0) + .LocalPositionY(0) + .LocalPositionZ(0) + .LocalRotation(Quaternion.identity) + .LocalScale(Vector3.one) + .LocalScaleX(1.0f) + .LocalScaleY(1.0f) + .Identity() + .PositionIdentity() + .RotationIdentity() + .Position(Vector3.zero) + .PositionX(0) + .PositionY(0) + .PositionZ(0) + .Rotation(Quaternion.identity) + .DestroyChildren() + .AsLastSibling() + .AsFirstSibling() + .SiblingIndex(0); + +selfScript + .Parent(null) + .LocalIdentity() + .LocalPositionIdentity() + .LocalRotationIdentity() + .LocalScaleIdentity() + .LocalPosition(Vector3.zero) + .LocalPosition(0, 0, 0) + .LocalPosition(0, 0) + .LocalPositionX(0) + .LocalPositionY(0) + .LocalPositionZ(0) + .LocalRotation(Quaternion.identity) + .LocalScale(Vector3.one) + .LocalScaleX(1.0f) + .LocalScaleY(1.0f) + .Identity() + .PositionIdentity() + .RotationIdentity() + .Position(Vector3.zero) + .PositionX(0) + .PositionY(0) + .PositionZ(0) + .Rotation(Quaternion.identity) + .DestroyChildren() + .AsLastSibling() + .AsFirstSibling() + .SiblingIndex(0); +")] +#endif + public static class UnityEngineTransformExtension + { +#if UNITY_EDITOR + // v1 No.65 + [MethodAPI] + [APIDescriptionCN("component.transform.SetParent(parent)")] + [APIDescriptionEN("component.transform.SetParent(parent)")] + [APIExampleCode(@" +myScript.Parent(rootGameObj); +")] +#endif + public static T Parent(this T self, Component parent) where T : Component + { + self.transform.SetParent(parent == null ? null : parent.transform); + return self; + } + +#if UNITY_EDITOR + // v1 No.66 + [MethodAPI] + [APIDescriptionCN("gameObject.transform.SetParent(parent)")] + [APIDescriptionEN("gameObject.transform.SetParent(parent)")] + [APIExampleCode(@" +gameObj.SetParent(null); +")] +#endif + public static GameObject Parent(this GameObject self, Component parent) + { + self.transform.SetParent(parent == null ? null : parent.transform); + return self; + } + +#if UNITY_EDITOR + // v1 No.67 + [MethodAPI] + [APIDescriptionCN("component.transform.SetParent(null)")] + [APIDescriptionEN("component.transform.SetParent(null)")] + [APIExampleCode(@" +component.AsRootTransform(); +")] +#endif + public static T AsRootTransform(this T self) where T : Component + { + self.transform.SetParent(null); + return self; + } + +#if UNITY_EDITOR + // v1 No.68 + [MethodAPI] + [APIDescriptionCN("gameObject.transform.SetParent(null)")] + [APIDescriptionEN("gameObject.transform.SetParent(null)")] + [APIExampleCode(@" +gameObject.AsRootGameObject(); +")] +#endif + public static GameObject AsRootGameObject(this GameObject self) + { + self.transform.SetParent(null); + return self; + } + + +#if UNITY_EDITOR + // v1 No.69 + [MethodAPI] + [APIDescriptionCN("设置本地位置为 0、本地角度为 0、本地缩放为 1")] + [APIDescriptionEN("set local pos:0 local angle:0 local scale:1")] + [APIExampleCode(@" +myScript.LocalIdentity(); +")] +#endif + public static T LocalIdentity(this T self) where T : Component + { + self.transform.localPosition = Vector3.zero; + self.transform.localRotation = Quaternion.identity; + self.transform.localScale = Vector3.one; + return self; + } + +#if UNITY_EDITOR + // v1 No.70 + [MethodAPI] + [APIDescriptionCN("设置 gameObject 的本地位置为 0、本地角度为 0、本地缩放为 1")] + [APIDescriptionEN("set gameObject's local pos:0 local angle:0 local scale:1")] + [APIExampleCode(@" +myScript.LocalIdentity(); +")] +#endif + public static GameObject LocalIdentity(this GameObject self) + { + self.transform.localPosition = Vector3.zero; + self.transform.localRotation = Quaternion.identity; + self.transform.localScale = Vector3.one; + return self; + } + + +#if UNITY_EDITOR + // v1 No.71 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = localPosition")] + [APIDescriptionEN("component.transform.localPosition = localPosition")] + [APIExampleCode(@" +spriteRenderer.LocalPosition(new Vector3(0,100,0)); +")] +#endif + public static T LocalPosition(this T selfComponent, Vector3 localPos) where T : Component + { + selfComponent.transform.localPosition = localPos; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.72 + [MethodAPI] + [APIDescriptionCN("gameObject.transform.localPosition = localPosition")] + [APIDescriptionEN("gameObject.transform.localPosition = localPosition")] + [APIExampleCode(@" +new GameObject().LocalPosition(new Vector3(0,100,0)); +")] +#endif + public static GameObject LocalPosition(this GameObject self, Vector3 localPos) + { + self.transform.localPosition = localPos; + return self; + } + +#if UNITY_EDITOR + // v1 No.73 + [MethodAPI] + [APIDescriptionCN("return component.transform.localPosition")] + [APIDescriptionEN("return component.transform.localPosition")] + [APIExampleCode(@" +var localPosition = spriteRenderer.LocalPosition(); +")] +#endif + public static Vector3 LocalPosition(this T selfComponent) where T : Component + { + return selfComponent.transform.localPosition; + } + +#if UNITY_EDITOR + // v1 No.74 + [MethodAPI] + [APIDescriptionCN("return gameObject.transform.localPosition")] + [APIDescriptionEN("return gameObject.transform.localPosition")] + [APIExampleCode(@" +Debug.Log(new GameObject().LocalPosition()); +")] +#endif + public static Vector3 LocalPosition(this GameObject self) + { + return self.transform.localPosition; + } + + +#if UNITY_EDITOR + // v1 No.75 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = new Vector3(x,y,z)")] + [APIDescriptionEN("component.transform.localPosition = new Vector3(x,y,z)")] + [APIExampleCode(@" +myScript.LocalPosition(0,0,-10); +")] +#endif + public static T LocalPosition(this T selfComponent, float x, float y, float z) where T : Component + { + selfComponent.transform.localPosition = new Vector3(x, y, z); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.76 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition = new Vector3(x,y,z)")] + [APIDescriptionEN("gameObj.transform.localPosition = new Vector3(x,y,z)")] + [APIExampleCode(@" +new GameObject().LocalPosition(0,0,-10); +")] +#endif + public static GameObject LocalPosition(this GameObject self, float x, float y, float z) + { + self.transform.localPosition = new Vector3(x, y, z); + return self; + } + + +#if UNITY_EDITOR + // v1 No.77 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = new Vector3(x,y,component.transform.localPosition.z)")] + [APIDescriptionEN("component.transform.localPosition = new Vector3(x,y,component.transform.localPosition.z)")] + [APIExampleCode(@" +myScript.LocalPosition(0,0); +")] +#endif + public static T LocalPosition(this T selfComponent, float x, float y) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.x = x; + localPosition.y = y; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.78 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition = new Vector3(x,y,gameObj.transform.localPosition.z)")] + [APIDescriptionEN("gameObj.transform.localPosition = new Vector3(x,y,gameObj.transform.localPosition.z)")] + [APIExampleCode(@" +new GameObject().LocalPosition(0,0); +")] +#endif + public static GameObject LocalPosition(this GameObject self, float x, float y) + { + var localPosition = self.transform.localPosition; + localPosition.x = x; + localPosition.y = y; + self.transform.localPosition = localPosition; + return self; + } + +#if UNITY_EDITOR + // v1 No.79 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition.x = x")] + [APIDescriptionEN("component.transform.localPosition.x = x")] + [APIExampleCode(@" +component.LocalPositionX(10); +")] +#endif + public static T LocalPositionX(this T selfComponent, float x) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.x = x; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.80 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition.x = x")] + [APIDescriptionEN("gameObj.transform.localPosition.x = x")] + [APIExampleCode(@" +gameObj.LocalPositionX(10); +")] +#endif + public static GameObject LocalPositionX(this GameObject self, float x) + { + var localPosition = self.transform.localPosition; + localPosition.x = x; + self.transform.localPosition = localPosition; + return self; + } + +#if UNITY_EDITOR + // v1 No.81 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition.y = y")] + [APIDescriptionEN("component.transform.localPosition.y = y")] + [APIExampleCode(@" +component.LocalPositionY(10); +")] +#endif + public static T LocalPositionY(this T selfComponent, float y) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.y = y; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.82 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition.y = y")] + [APIDescriptionEN("gameObj.transform.localPosition.y = y")] + [APIExampleCode(@" +gameObj.LocalPositionY(10); +")] +#endif + + public static GameObject LocalPositionY(this GameObject selfComponent, float y) + { + var localPosition = selfComponent.transform.localPosition; + localPosition.y = y; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.83 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition.z = z")] + [APIDescriptionEN("component.transform.localPosition.z = z")] + [APIExampleCode(@" +component.LocalPositionZ(10); +")] +#endif + public static T LocalPositionZ(this T selfComponent, float z) where T : Component + { + var localPosition = selfComponent.transform.localPosition; + localPosition.z = z; + selfComponent.transform.localPosition = localPosition; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.84 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition.z = z")] + [APIDescriptionEN("gameObj.transform.localPosition.z = z")] + [APIExampleCode(@" +gameObj.LocalPositionZ(10); +")] +#endif + public static GameObject LocalPositionZ(this GameObject self, float z) + { + var localPosition = self.transform.localPosition; + localPosition.z = z; + self.transform.localPosition = localPosition; + return self; + } + + +#if UNITY_EDITOR + // v1 No.85 + [MethodAPI] + [APIDescriptionCN("component.transform.localPosition = Vector3.zero")] + [APIDescriptionEN("component.transform.localPosition = Vector3.zero")] + [APIExampleCode(@" +component.LocalPositionIdentity(); +")] +#endif + public static T LocalPositionIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.localPosition = Vector3.zero; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.86 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localPosition = Vector3.zero")] + [APIDescriptionEN("gameObj.transform.localPosition = Vector3.zero")] + [APIExampleCode(@" +gameObj.LocalPositionIdentity(); +")] +#endif + public static GameObject LocalPositionIdentity(this GameObject self) + { + self.transform.localPosition = Vector3.zero; + return self; + } + + +#if UNITY_EDITOR + // v1 No.87 + [MethodAPI] + [APIDescriptionCN("return component.transform.localRotation")] + [APIDescriptionEN("return component.transform.localRotation")] + [APIExampleCode(@" +var localRotation = myScript.LocalRotation(); +")] +#endif + public static Quaternion LocalRotation(this T selfComponent) where T : Component + { + return selfComponent.transform.localRotation; + } + +#if UNITY_EDITOR + // v1 No.88 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.localRotation")] + [APIDescriptionEN("return gameObj.transform.localRotation")] + [APIExampleCode(@" +var localRotation = gameObj.LocalRotation(); +")] +#endif + public static Quaternion LocalRotation(this GameObject self) + { + return self.transform.localRotation; + } + +#if UNITY_EDITOR + // v1 No.89 + [MethodAPI] + [APIDescriptionCN("component.transform.localRotation = localRotation")] + [APIDescriptionEN("component.transform.localRotation = localRotation")] + [APIExampleCode(@" +myScript.LocalRotation(Quaternion.identity); +")] +#endif + public static T LocalRotation(this T selfComponent, Quaternion localRotation) where T : Component + { + selfComponent.transform.localRotation = localRotation; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.90 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localRotation = localRotation")] + [APIDescriptionEN("gameObj.transform.localRotation = localRotation")] + [APIExampleCode(@" +gameObj.LocalRotation(Quaternion.identity); +")] +#endif + public static GameObject LocalRotation(this GameObject selfComponent, Quaternion localRotation) + { + selfComponent.transform.localRotation = localRotation; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.91 + [MethodAPI] + [APIDescriptionCN("component.transform.localRotation = Quaternion.identity")] + [APIDescriptionEN("component.transform.localRotation = Quaternion.identity")] + [APIExampleCode(@" +component.LocalRotationIdentity(); +")] +#endif + public static T LocalRotationIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.localRotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.92 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localRotation = Quaternion.identity")] + [APIDescriptionEN("gameObj.transform.localRotation = Quaternion.identity")] + [APIExampleCode(@" +gameObj.LocalRotationIdentity(); +")] +#endif + public static GameObject LocalRotationIdentity(this GameObject selfComponent) + { + selfComponent.transform.localRotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.93 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = scale")] + [APIDescriptionEN("component.transform.localScale = scale")] + [APIExampleCode(@" +component.LocalScale(Vector3.one); +")] +#endif + public static T LocalScale(this T selfComponent, Vector3 scale) where T : Component + { + selfComponent.transform.localScale = scale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.94 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = scale")] + [APIDescriptionEN("gameObj.transform.localScale = scale")] + [APIExampleCode(@" +gameObj.LocalScale(Vector3.one); +")] +#endif + public static GameObject LocalScale(this GameObject self, Vector3 scale) + { + self.transform.localScale = scale; + return self; + } + + +#if UNITY_EDITOR + // v1 No.95 + [MethodAPI] + [APIDescriptionCN("return component.transform.localScale")] + [APIDescriptionEN("return component.transform.localScale")] + [APIExampleCode(@" +var localScale = myScript.LocalScale(); +")] +#endif + public static Vector3 LocalScale(this T selfComponent) where T : Component + { + return selfComponent.transform.localScale; + } + +#if UNITY_EDITOR + // v1 No.96 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.localScale")] + [APIDescriptionEN("return gameObj.transform.localScale")] + [APIExampleCode(@" +var localScale = gameObj.LocalScale(); +")] +#endif + public static Vector3 LocalScale(this GameObject self) + { + return self.transform.localScale; + } + + +#if UNITY_EDITOR + // v1 No.97 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = new Vector3(xyz,xyz,xyz)")] + [APIDescriptionEN("component.transform.localScale = new Vector3(xyz,xyz,xyz)")] + [APIExampleCode(@" +myScript.LocalScale(1); +")] +#endif + public static T LocalScale(this T selfComponent, float xyz) where T : Component + { + selfComponent.transform.localScale = Vector3.one * xyz; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.98 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = new Vector3(scale,scale,scale)")] + [APIDescriptionEN("gameObj.transform.localScale = new Vector3(scale,scale,scale)")] + [APIExampleCode(@" +gameObj.LocalScale(1); +")] +#endif + public static GameObject LocalScale(this GameObject self, float xyz) + { + self.transform.localScale = Vector3.one * xyz; + return self; + } + +#if UNITY_EDITOR + // v1 No.99 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = new Vector3(x,y,z)")] + [APIDescriptionEN("component.transform.localScale = new Vector3(x,y,z)")] + [APIExampleCode(@" +myScript.LocalScale(2,2,2); +")] +#endif + public static T LocalScale(this T selfComponent, float x, float y, float z) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.100 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = new Vector3(x,y,z)")] + [APIDescriptionEN("gameObj.transform.localScale = new Vector3(x,y,z)")] + [APIExampleCode(@" +gameObj.LocalScale(2,2,2); +")] +#endif + public static GameObject LocalScale(this GameObject selfComponent, float x, float y, float z) + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.101 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = new Vector3(x,y,component.transform.localScale.z)")] + [APIDescriptionEN("component.transform.localScale = new Vector3(x,y,component.transform.localScale.z)")] + [APIExampleCode(@" +component.LocalScale(2,2); +")] +#endif + public static T LocalScale(this T selfComponent, float x, float y) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.102 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale = new Vector3(x,y,gameObj.transform.localScale.z)")] + [APIDescriptionEN("gameObj.transform.localScale = new Vector3(x,y,gameObj.transform.localScale.z)")] + [APIExampleCode(@" +gameObj.LocalScale(2,2); +")] +#endif + public static GameObject LocalScale(this GameObject selfComponent, float x, float y) + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + localScale.y = y; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.103 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.x = x")] + [APIDescriptionEN("component.transform.localScale.x = x)")] + [APIExampleCode(@" +component.LocalScaleX(10); +")] +#endif + public static T LocalScaleX(this T selfComponent, float x) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.x = x; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.104 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.x = x")] + [APIDescriptionEN("gameObj.transform.localScale.x = x)")] + [APIExampleCode(@" +gameObj.LocalScaleX(10); +")] +#endif + public static GameObject LocalScaleX(this GameObject self, float x) + { + var localScale = self.transform.localScale; + localScale.x = x; + self.transform.localScale = localScale; + return self; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.x")] + [APIDescriptionEN("gameObj.transform.localScale.x)")] + [APIExampleCode(@" +var scaleX = gameObj.LocalScaleX(); +")] +#endif + public static float LocalScaleX(this GameObject self) + { + return self.transform.localScale.x; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.x")] + [APIDescriptionEN("component.transform.localScale.x)")] + [APIExampleCode(@" +var scaleX = component.LocalScaleX(); +")] +#endif + public static float LocalScaleX(this T self) where T : Component + { + return self.transform.localScale.x; + } + + +#if UNITY_EDITOR + // v1 No.105 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.y = y")] + [APIDescriptionEN("component.transform.localScale.y = y)")] + [APIExampleCode(@" +component.LocalScaleY(10); +")] +#endif + public static T LocalScaleY(this T self, float y) where T : Component + { + var localScale = self.transform.localScale; + localScale.y = y; + self.transform.localScale = localScale; + return self; + } + +#if UNITY_EDITOR + // v1 No.106 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.y = y")] + [APIDescriptionEN("gameObj.transform.localScale.y = y)")] + [APIExampleCode(@" +gameObj.LocalScaleY(10); +")] +#endif + public static GameObject LocalScaleY(this GameObject self, float y) + { + var localScale = self.transform.localScale; + localScale.y = y; + self.transform.localScale = localScale; + return self; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.y")] + [APIDescriptionEN("component.transform.localScale.y)")] + [APIExampleCode(@" +var scaleY = component.LocalScaleY(10); +")] +#endif + public static float LocalScaleY(this T self) where T : Component + { + return self.transform.localScale.y; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.y")] + [APIDescriptionEN("gameObj.transform.localScale.y)")] + [APIExampleCode(@" +var scaleY = gameObj.LocalScaleY(); +")] +#endif + public static float LocalScaleY(this GameObject self) + { + return self.transform.localScale.y; + } + + +#if UNITY_EDITOR + // v1 No.107 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.z = z")] + [APIDescriptionEN("component.transform.localScale.z = z)")] + [APIExampleCode(@" +component.LocalScaleZ(10); +")] +#endif + public static T LocalScaleZ(this T selfComponent, float z) where T : Component + { + var localScale = selfComponent.transform.localScale; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.108 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.z = z")] + [APIDescriptionEN("gameObj.transform.localScale.z = z)")] + [APIExampleCode(@" +gameObj.LocalScaleZ(10); +")] +#endif + public static GameObject LocalScaleZ(this GameObject selfComponent, float z) + { + var localScale = selfComponent.transform.localScale; + localScale.z = z; + selfComponent.transform.localScale = localScale; + return selfComponent; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale.z")] + [APIDescriptionEN("component.transform.localScale.z)")] + [APIExampleCode(@" +var scaleZ = component.LocalScaleZ(); +")] +#endif + public static float LocalScaleZ(this T self) where T : Component + { + return self.transform.localScale.z; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.localScale.z")] + [APIDescriptionEN("gameObj.transform.localScale.z)")] + [APIExampleCode(@" +var scaleZ = gameObj.LocalScaleZ(); +")] +#endif + public static float LocalScaleZ(this GameObject self) + { + return self.transform.localScale.z; + } + + +#if UNITY_EDITOR + // v1 No.109 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = Vector3.one")] + [APIDescriptionEN("component.transform.localScale = Vector3.one)")] + [APIExampleCode(@" +component.LocalScaleIdentity(); +")] +#endif + public static T LocalScaleIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.localScale = Vector3.one; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.110 + [MethodAPI] + [APIDescriptionCN("component.transform.localScale = Vector3.one")] + [APIDescriptionEN("component.transform.localScale = Vector3.one)")] + [APIExampleCode(@" +component.LocalScaleIdentity(); +")] +#endif + public static GameObject LocalScaleIdentity(this GameObject selfComponent) + { + selfComponent.transform.localScale = Vector3.one; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.111 + [MethodAPI] + [APIDescriptionCN("设置世界位置:0 角度:0 缩放:1")] + [APIDescriptionEN("set world pos:0 rotation:0 scale:1")] + [APIExampleCode(@" +component.Identity(); +")] +#endif + public static T Identity(this T selfComponent) where T : Component + { + selfComponent.transform.position = Vector3.zero; + selfComponent.transform.rotation = Quaternion.identity; + selfComponent.transform.localScale = Vector3.one; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.112 + [MethodAPI] + [APIDescriptionCN("设置世界位置:0 角度:0 缩放:1")] + [APIDescriptionEN("set world pos:0 rotation:0 scale:1")] + [APIExampleCode(@" +component.Identity(); +")] +#endif + public static GameObject Identity(this GameObject self) + { + self.transform.position = Vector3.zero; + self.transform.rotation = Quaternion.identity; + self.transform.localScale = Vector3.one; + return self; + } + +#if UNITY_EDITOR + // v1 No.113 + [MethodAPI] + [APIDescriptionCN("component.transform.position = position")] + [APIDescriptionEN("component.transform.position = position")] + [APIExampleCode(@" +component.Position(Vector3.zero); +")] +#endif + public static T Position(this T selfComponent, Vector3 position) where T : Component + { + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.114 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = position")] + [APIDescriptionEN("gameObj.transform.position = position")] + [APIExampleCode(@" +gameObj.Position(Vector3.zero); +")] +#endif + public static GameObject Position(this GameObject self, Vector3 position) + { + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.115 + [MethodAPI] + [APIDescriptionCN("return component.transform.position")] + [APIDescriptionEN("return component.transform.position")] + [APIExampleCode(@" +var pos = myScript.Position(); +")] +#endif + public static Vector3 Position(this T selfComponent) where T : Component + { + return selfComponent.transform.position; + } + +#if UNITY_EDITOR + // v1 No.116 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.position")] + [APIDescriptionEN("return gameObj.transform.position")] + [APIExampleCode(@" +var pos = gameObj.Position(); +")] +#endif + public static Vector3 Position(this GameObject self) + { + return self.transform.position; + } + +#if UNITY_EDITOR + // v1 No.117 + [MethodAPI] + [APIDescriptionCN("component.transform.position = new Vector3(x,y,z)")] + [APIDescriptionEN("component.transform.position = new Vector3(x,y,z)")] + [APIExampleCode(@" +myScript.Position(0,0,-10); +")] +#endif + public static T Position(this T selfComponent, float x, float y, float z) where T : Component + { + selfComponent.transform.position = new Vector3(x, y, z); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.118 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = new Vector3(x,y,z)")] + [APIDescriptionEN("gameObj.transform.position = new Vector3(x,y,z)")] + [APIExampleCode(@" +gameObj.Position(0,0,-10); +")] +#endif + public static GameObject Position(this GameObject self, float x, float y, float z) + { + self.transform.position = new Vector3(x, y, z); + return self; + } + +#if UNITY_EDITOR + // v1 No.119 + [MethodAPI] + [APIDescriptionCN("component.transform.position = new Vector3(x,y,原来的 z)")] + [APIDescriptionEN("component.transform.position = new Vector3(x,y,origin z)")] + [APIExampleCode(@" +component.Position(0,0); +")] +#endif + public static T Position(this T selfComponent, float x, float y) where T : Component + { + var position = selfComponent.transform.position; + position.x = x; + position.y = y; + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.120 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = new Vector3(x,y,原来的 z)")] + [APIDescriptionEN("gameObj.transform.position = new Vector3(x,y,origin z)")] + [APIExampleCode(@" +gameObj.Position(0,0,-10); +")] +#endif + public static GameObject Position(this GameObject selfComponent, float x, float y) + { + var position = selfComponent.transform.position; + position.x = x; + position.y = y; + selfComponent.transform.position = position; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.121 + [MethodAPI] + [APIDescriptionCN("component.transform.position = Vector3.zero")] + [APIDescriptionEN("component.transform.position = Vector3.zero")] + [APIExampleCode(@" +component.PositionIdentity(); +")] +#endif + public static T PositionIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.position = Vector3.zero; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.122 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position = Vector3.zero")] + [APIDescriptionEN("gameObj.transform.position = Vector3.zero")] + [APIExampleCode(@" +gameObj.PositionIdentity(); +")] +#endif + public static GameObject PositionIdentity(this GameObject selfComponent) + { + selfComponent.transform.position = Vector3.zero; + return selfComponent; + } + + +#if UNITY_EDITOR + // v1 No.121 + [MethodAPI] + [APIDescriptionCN("component.transform.position.x = x")] + [APIDescriptionEN("component.transform.position.x = x")] + [APIExampleCode(@" +component.PositionX(x); +")] +#endif + public static T PositionX(this T selfComponent, float x) where T : Component + { + var position = selfComponent.transform.position; + position.x = x; + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.122 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.position.x = x")] + [APIDescriptionEN("gameObj.transform.position.x = x")] + [APIExampleCode(@" +gameObj.PositionX(x); +")] +#endif + public static GameObject PositionX(this GameObject self, float x) + { + var position = self.transform.position; + position.x = x; + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.123 + [MethodAPI] + [APIDescriptionCN("将 positionX 的计算结果设置给 position.x")] + [APIDescriptionEN("Sets the positionX calculation to position.x")] + [APIExampleCode(@" +component.PositionX(x=>x * 5); +")] +#endif + public static T PositionX(this T selfComponent, Func xSetter) where T : Component + { + var position = selfComponent.transform.position; + position.x = xSetter(position.x); + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.124 + [MethodAPI] + [APIDescriptionCN("将 positionX 的计算结果设置给 position.x")] + [APIDescriptionEN("Sets the positionX calculation to position.x")] + [APIExampleCode(@" +gameObj.PositionX(x=>x * 5); +")] +#endif + public static GameObject PositionX(this GameObject self, Func xSetter) + { + var position = self.transform.position; + position.x = xSetter(position.x); + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.125 + [MethodAPI] + [APIDescriptionCN("component.transform.position.y = y")] + [APIDescriptionEN("component.transform.position.y = y")] + [APIExampleCode(@" +myScript.PositionY(10); +")] +#endif + public static T PositionY(this T selfComponent, float y) where T : Component + { + var position = selfComponent.transform.position; + position.y = y; + selfComponent.transform.position = position; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.126 + [MethodAPI] + [APIDescriptionCN("component.transform.position.y = y")] + [APIDescriptionEN("component.transform.position.y = y")] + [APIExampleCode(@" +myScript.PositionY(10); +")] +#endif + public static GameObject PositionY(this GameObject self, float y) + { + var position = self.transform.position; + position.y = y; + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.127 + [MethodAPI] + [APIDescriptionCN("将 positionY 的计算结果设置给 position.y")] + [APIDescriptionEN("Sets the positionY calculation to position.y")] + [APIExampleCode(@" +component.PositionY(y=>y * 5); +")] +#endif + public static T PositionY(this T selfComponent, Func ySetter) where T : Component + { + var position = selfComponent.transform.position; + position.y = ySetter(position.y); + selfComponent.transform.position = position; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.128 + [MethodAPI] + [APIDescriptionCN("将 positionY 的计算结果设置给 position.y")] + [APIDescriptionEN("Sets the positionY calculation to position.y")] + [APIExampleCode(@" +gameObj.PositionY(y=>y * 5); +")] +#endif + public static GameObject PositionY(this GameObject self, Func ySetter) + { + var position = self.transform.position; + position.y = ySetter(position.y); + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.129 + [MethodAPI] + [APIDescriptionCN("component.transform.position.z = z")] + [APIDescriptionEN("component.transform.position.z = z")] + [APIExampleCode(@" +component.PositionZ(10); +")] +#endif + public static T PositionZ(this T selfComponent, float z) where T : Component + { + var position = selfComponent.transform.position; + position.z = z; + selfComponent.transform.position = position; + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.130 + [MethodAPI] + [APIDescriptionCN("component.transform.position.z = z")] + [APIDescriptionEN("component.transform.position.z = z")] + [APIExampleCode(@" +component.PositionZ(10); +")] +#endif + public static GameObject PositionZ(this GameObject self, float z) + { + var position = self.transform.position; + position.z = z; + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.131 + [MethodAPI] + [APIDescriptionCN("将 positionZ 的计算结果设置给 position.z")] + [APIDescriptionEN("Sets the positionZ calculation to position.z")] + [APIExampleCode(@" +component.PositionZ(z=>z * 5); +")] +#endif + public static T PositionZ(this T self, Func zSetter) where T : Component + { + var position = self.transform.position; + position.z = zSetter(position.z); + self.transform.position = position; + return self; + } + +#if UNITY_EDITOR + // v1 No.132 + [MethodAPI] + [APIDescriptionCN("将 positionZ 的计算结果设置给 position.z")] + [APIDescriptionEN("Sets the positionZ calculation to position.z")] + [APIExampleCode(@" +component.PositionZ(z=>z * 5); +")] +#endif + public static GameObject PositionZ(this GameObject self, Func zSetter) + { + var position = self.transform.position; + position.z = zSetter(position.z); + self.transform.position = position; + return self; + } + + +#if UNITY_EDITOR + // v1 No.133 + [MethodAPI] + [APIDescriptionCN("component.transform.rotation = Quaternion.identity")] + [APIDescriptionEN("component.transform.rotation = Quaternion.identity")] + [APIExampleCode(@" +component.RotationIdentity(); +")] +#endif + public static T RotationIdentity(this T selfComponent) where T : Component + { + selfComponent.transform.rotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.134 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.rotation = Quaternion.identity")] + [APIDescriptionEN("gameObj.transform.rotation = Quaternion.identity")] + [APIExampleCode(@" +gameObj.RotationIdentity(); +")] +#endif + public static GameObject RotationIdentity(this GameObject selfComponent) + { + selfComponent.transform.rotation = Quaternion.identity; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.135 + [MethodAPI] + [APIDescriptionCN("component.transform.rotation = rotation")] + [APIDescriptionEN("component.transform.rotation = rotation")] + [APIExampleCode(@" +component.Rotation(Quaternion.identity); +")] +#endif + public static T Rotation(this T selfComponent, Quaternion rotation) where T : Component + { + selfComponent.transform.rotation = rotation; + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.136 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.rotation = rotation")] + [APIDescriptionEN("gameObj.transform.rotation = rotation")] + [APIExampleCode(@" +gameObj.Rotation(Quaternion.identity); +")] +#endif + public static GameObject Rotation(this GameObject self, Quaternion rotation) + { + self.transform.rotation = rotation; + return self; + } + +#if UNITY_EDITOR + // v1 No.137 + [MethodAPI] + [APIDescriptionCN("return component.transform.rotation")] + [APIDescriptionEN("return component.transform.rotation")] + [APIExampleCode(@" +var rotation = myScript.Rotation(); +")] +#endif + public static Quaternion Rotation(this T selfComponent) where T : Component + { + return selfComponent.transform.rotation; + } + +#if UNITY_EDITOR + // v1 No.138 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.rotation")] + [APIDescriptionEN("return gameObj.transform.rotation")] + [APIExampleCode(@" +var rotation = gameObj.Rotation(); +")] +#endif + public static Quaternion Rotation(this GameObject self) + { + return self.transform.rotation; + } + + +#if UNITY_EDITOR + // v1 No.139 + [MethodAPI] + [APIDescriptionCN("return component.transform.lossyScale")] + [APIDescriptionEN("return component.transform.lossyScale")] + [APIExampleCode(@" +var scale = component.Scale(); +")] +#endif + public static Vector3 Scale(this T selfComponent) where T : Component + { + return selfComponent.transform.lossyScale; + } + +#if UNITY_EDITOR + // v1 No.140 + [MethodAPI] + [APIDescriptionCN("return gameObj.transform.lossyScale")] + [APIDescriptionEN("return gameObj.transform.lossyScale")] + [APIExampleCode(@" +var scale = gameObj.Scale(); +")] +#endif + public static Vector3 Scale(this GameObject selfComponent) + { + return selfComponent.transform.lossyScale; + } + + +#if UNITY_EDITOR + // v1 No.141 + [MethodAPI] + [APIDescriptionCN("Destroy 掉所有的子 GameObject")] + [APIDescriptionEN("destroy all child gameObjects")] + [APIExampleCode(@" +rootTransform.DestroyChildren(); +")] +#endif + public static T DestroyChildren(this T selfComponent) where T : Component + { + var childCount = selfComponent.transform.childCount; + + for (var i = childCount - 1; i >= 0; i--) + { + selfComponent.transform.GetChild(i).DestroyGameObjGracefully(); + } + + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.141.1 + [MethodAPI] + [APIDescriptionCN("根据条件 Destroy 掉所有的子 GameObject ")] + [APIDescriptionEN("destroy all child gameObjects if condition matched")] + [APIExampleCode(@" +rootTransform.DestroyChildrenWithCondition(child=>child != other); +")] +#endif + public static T DestroyChildrenWithCondition(this T selfComponent, Func condition) + where T : Component + { + var childCount = selfComponent.transform.childCount; + + for (var i = childCount - 1; i >= 0; i--) + { + var child = selfComponent.transform.GetChild(i); + if (condition(child)) + { + child.DestroyGameObjGracefully(); + } + } + + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.142 + [MethodAPI] + [APIDescriptionCN("Destroy 掉所有的子 GameObject")] + [APIDescriptionEN("destroy all child gameObjects")] + [APIExampleCode(@" +rootGameObj.DestroyChildren(); +")] +#endif + public static GameObject DestroyChildren(this GameObject selfGameObj) + { + var childCount = selfGameObj.transform.childCount; + + for (var i = childCount - 1; i >= 0; i--) + { + selfGameObj.transform.GetChild(i).DestroyGameObjGracefully(); + } + + return selfGameObj; + } + + +#if UNITY_EDITOR + // v1 No.143 + [MethodAPI] + [APIDescriptionCN("component.transform.SetAsLastSibling()")] + [APIDescriptionEN("component.transform.SetAsLastSibling()")] + [APIExampleCode(@" +myScript.AsLastSibling(); +")] +#endif + public static T AsLastSibling(this T selfComponent) where T : Component + { + selfComponent.transform.SetAsLastSibling(); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.144 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.SetAsLastSibling()")] + [APIDescriptionEN("gameObj.transform.SetAsLastSibling()")] + [APIExampleCode(@" +gameObj.AsLastSibling(); +")] +#endif + public static GameObject AsLastSibling(this GameObject self) + { + self.transform.SetAsLastSibling(); + return self; + } + +#if UNITY_EDITOR + // v1 No.145 + [MethodAPI] + [APIDescriptionCN("component.transform.SetAsFirstSibling()")] + [APIDescriptionEN("component.transform.SetAsFirstSibling()")] + [APIExampleCode(@" +component.AsFirstSibling(); +")] +#endif + public static T AsFirstSibling(this T selfComponent) where T : Component + { + selfComponent.transform.SetAsFirstSibling(); + return selfComponent; + } +#if UNITY_EDITOR + // v1 No.146 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.SetAsFirstSibling()")] + [APIDescriptionEN("gameObj.transform.SetAsFirstSibling()")] + [APIExampleCode(@" +gameObj.AsFirstSibling(); +")] +#endif + public static GameObject AsFirstSibling(this GameObject selfComponent) + { + selfComponent.transform.SetAsFirstSibling(); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.147 + [MethodAPI] + [APIDescriptionCN("component.transform.SetSiblingIndex(index)")] + [APIDescriptionEN("component.transform.SetSiblingIndex(index)")] + [APIExampleCode(@" +myScript.SiblingIndex(10); +")] +#endif + public static T SiblingIndex(this T selfComponent, int index) where T : Component + { + selfComponent.transform.SetSiblingIndex(index); + return selfComponent; + } + +#if UNITY_EDITOR + // v1 No.148 + [MethodAPI] + [APIDescriptionCN("gameObj.transform.SetSiblingIndex(index)")] + [APIDescriptionEN("gameObj.transform.SetSiblingIndex(index)")] + [APIExampleCode(@" +gameObj.SiblingIndex(10); +")] +#endif + public static GameObject SiblingIndex(this GameObject selfComponent, int index) + { + selfComponent.transform.SetSiblingIndex(index); + return selfComponent; + } + + public static Vector2 Position2D(this GameObject self) => new Vector2(self.transform.position.x, self.transform.position.y); + + public static Vector2 Position2D(this Component self) => new Vector2(self.transform.position.x, self.transform.position.y); + + public static GameObject Position2D(this GameObject self, Vector2 position) => self.Position(position.x, position.y); + + public static GameObject Position2D(this GameObject self, float x, float y) => self.Position(x, y); + + public static T Position2D(this T self, float x,float y) where T : Component => self.Position(x, y); + + public static T Position2D(this T self, Vector2 position) where T : Component => self.Position(position.x, position.y); + + public static Vector2 LocalPosition2D(this GameObject self) => new Vector2(self.transform.localPosition.x, self.transform.localPosition.y); + + public static Vector2 LocalPosition2D(this Component self) => new Vector2(self.transform.localPosition.x, self.transform.localPosition.y); + + public static GameObject LocalPosition2D(this GameObject self, Vector2 position) => self.LocalPosition(position.x, position.y); + + public static T LocalPosition2D(this T self, Vector2 position) where T : Component => self.LocalPosition(position.x, position.y); + + public static GameObject SyncPositionFrom(this GameObject self, GameObject from) => self.Position(from.Position()); + + public static T SyncPositionFrom(this T self, GameObject from) where T : Component => self.Position(from.Position()); + + public static GameObject SyncPositionFrom(this GameObject self, Component from) where T : Component => self.Position(from.Position()); + + public static T SyncPositionFrom(this T self, Component from) where T : Component => self.Position(from.Position()); + + public static GameObject SyncPosition2DFrom(this GameObject self, GameObject from) => + self.Position2D(from.Position2D()); + + public static T SyncPosition2DFrom(this T self, GameObject from) where T : Component => + self.Position2D(from.Position2D()); + + public static GameObject SyncPosition2DFrom(this GameObject self, Component from) => + self.Position2D(from.Position2D()); + + public static T SyncPosition2DFrom(this T self, Component from) where T : Component => + self.Position2D(from.Position2D()); + + + public static GameObject SyncPositionTo(this GameObject self, GameObject to) + { + to.Position(self.Position()); + return self; + } + + public static GameObject SyncPositionTo(this GameObject self, Component to) + { + to.Position(self.Position()); + return self; + } + + public static T SyncPositionTo(this T self, GameObject to) where T : Component + { + to.Position(self.Position()); + return self; + } + + public static T SyncPositionTo(this T self, Component to) where T : Component + { + to.Position(self.Position()); + return self; + } + + public static GameObject SyncPosition2DTo(this GameObject self, GameObject to) + { + to.Position2D(self.Position2D()); + return self; + } + + public static GameObject SyncPosition2DTo(this GameObject self, Component to) + { + to.Position2D(self.Position2D()); + return self; + } + + public static T SyncPosition2DTo(this T self, GameObject to) where T : Component + { + to.Position2D(self.Position2D()); + return self; + } + + public static T SyncPosition2DTo(this T self, Component to) where T : Component + { + to.Position2D(self.Position2D()); + return self; + } + + public static float PositionX(this GameObject self) => self.transform.position.x; + + public static float PositionX(this Component self) => self.transform.position.x; + + public static float PositionY(this GameObject self) => self.transform.position.y; + + public static float PositionY(this Component self) => self.transform.position.y; + + public static float PositionZ(this GameObject self) => self.transform.position.z; + + public static float PositionZ(this Component self) => self.transform.position.z; + + public static float LocalPositionX(this GameObject self) => self.transform.localPosition.x; + + public static float LocalPositionX(this Component self) => self.transform.localPosition.x; + + public static float LocalPositionY(this GameObject self) => self.transform.localPosition.y; + + public static float LocalPositionY(this Component self) => self.transform.localPosition.y; + + public static float LocalPositionZ(this GameObject self) => self.transform.localPosition.z; + + public static float LocalPositionZ(this Component self) => self.transform.localPosition.z; + public static Vector3 LocalEulerAngles(this GameObject self) => self.transform.localEulerAngles; + public static Vector3 LocalEulerAngles(this Component self) => self.transform.localEulerAngles; + + public static GameObject LocalEulerAngles(this GameObject self, Vector3 localEulerAngles) + { + self.transform.localEulerAngles = localEulerAngles; + return self; + } + + public static T LocalEulerAngles(this T self, Vector3 localEulerAngles) where T : Component + { + self.transform.localEulerAngles = localEulerAngles; + return self; + } + + public static GameObject LocalEulerAnglesZ(this GameObject self, float z) + { + self.LocalEulerAngles(self.LocalEulerAngles().Z(z)); + return self; + } + + public static T LocalEulerAnglesZ(this T self, float z) where T : Component + { + self.LocalEulerAngles(self.LocalEulerAngles().Z(z)); + return self; + } + + + public static Vector3 EulerAngles(this GameObject self) => self.transform.eulerAngles; + public static Vector3 EulerAngles(this Component self) => self.transform.eulerAngles; + + public static GameObject EulerAngles(this GameObject self, Vector3 eulerAngles) + { + self.transform.eulerAngles = eulerAngles; + return self; + } + + public static T EulerAngles(this T self, Vector3 eulerAngles) where T : Component + { + self.transform.eulerAngles = eulerAngles; + return self; + } + + public static GameObject EulerAnglesZ(this GameObject self, float z) + { + self.EulerAngles(self.EulerAngles().Z(z)); + return self; + } + + public static T EulerAnglesZ(this T self, float z) where T : Component + { + self.EulerAngles(self.EulerAngles().Z(z)); + return self; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs.meta new file mode 100644 index 0000000..b55f277 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/2.UnityEngineTransformExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a4b2070a7f53455e8ecc24c4d79c0a22 +timeCreated: 1647492399 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs new file mode 100644 index 0000000..c7b9d83 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs @@ -0,0 +1,52 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.MonoBehaviour", 3)] + [APIDescriptionCN("MonoBehaviour 静态扩展")] + [APIDescriptionEN("MonoBehaviour extension")] +#endif + public static class UnityEngineMonoBehaviourExtension + { + public static void Example() + { + var gameObject = new GameObject(); + var component = gameObject.GetComponent(); + + component.Enable(); // component.enabled = true + component.Disable(); // component.enabled = false + } + +#if UNITY_EDITOR + // v1 No.149 + [MethodAPI] + [APIDescriptionCN("monoBehaviour.enable = true")] + [APIDescriptionEN("monoBehaviour.enable = true)")] + [APIExampleCode(@" +myScript.Enable(); +")] +#endif + public static T Enable(this T selfBehaviour, bool enable = true) where T : Behaviour + { + selfBehaviour.enabled = enable; + return selfBehaviour; + } + +#if UNITY_EDITOR + // v1 No.150 + [MethodAPI] + [APIDescriptionCN("monoBehaviour.enable = false")] + [APIDescriptionEN("monoBehaviour.enable = false")] + [APIExampleCode(@" +myScript.Disable(); +")] +#endif + public static T Disable(this T selfBehaviour) where T : Behaviour + { + selfBehaviour.enabled = false; + return selfBehaviour; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs.meta new file mode 100644 index 0000000..e30204b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/3.UnityEngineMonoBehaviourExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8de3fdd3a4964430b98cbc29c78e56f3 +timeCreated: 1647507236 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs new file mode 100644 index 0000000..de09d7f --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs @@ -0,0 +1,41 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Camera", 4)] + [APIDescriptionCN("UnityEngine.Camera 静态扩展")] + [APIDescriptionEN("UnityEngine.Camera extension")] +#endif + public static class UnityEngineCameraExtension + { +#if UNITY_EDITOR + // v1 No.151 + [MethodAPI] + [APIDescriptionCN("截图")] + [APIDescriptionEN("captureScreen")] + [APIExampleCode(@" +Camera.main.CaptureCamera(new Rect(0, 0, Screen.width, Screen.height)); +")] +#endif + public static Texture2D CaptureCamera(this Camera camera, Rect rect) + { + var renderTexture = new RenderTexture(Screen.width, Screen.height, 0); + camera.targetTexture = renderTexture; + camera.Render(); + + RenderTexture.active = renderTexture; + + var screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false); + screenShot.ReadPixels(rect, 0, 0); + screenShot.Apply(); + + camera.targetTexture = null; + RenderTexture.active = null; + UnityEngine.Object.Destroy(renderTexture); + + return screenShot; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs.meta new file mode 100644 index 0000000..43e474a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/4.UnityEngineCameraExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 20fcd7ffbe7a4e6eb0a874c17e9d20ac +timeCreated: 1647507743 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs new file mode 100644 index 0000000..a0033f0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs @@ -0,0 +1,29 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Color", 5)] + [APIDescriptionCN("UnityEngine.Color 静态扩展")] + [APIDescriptionEN("UnityEngine.Color extension")] +#endif + public static class UnityEngineColorExtension + { +#if UNITY_EDITOR + // v1 No.152 + [MethodAPI] + [APIDescriptionCN("HTML string(#000000) 转 Color")] + [APIDescriptionEN("HTML string(like #000000)")] + [APIExampleCode(@" +var color = ""#C5563CFF"".HtmlStringToColor(); +Debug.Log(color);" + )] +#endif + public static Color HtmlStringToColor(this string htmlString) + { + var parseSucceed = ColorUtility.TryParseHtmlString(htmlString, out var retColor); + return parseSucceed ? retColor : Color.black; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs.meta new file mode 100644 index 0000000..514212e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/5.UnityEngineColorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 373d8df28d2643bc823a4326ba396126 +timeCreated: 1647507950 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs new file mode 100644 index 0000000..635baaf --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs @@ -0,0 +1,54 @@ + +using UnityEngine.UI; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Graphic", 6)] + [APIDescriptionCN("UnityEngine.UI.Graphic 静态扩展")] + [APIDescriptionEN("UnityEngine.UI.Graphic extension")] +#endif + public static class UnityEngineUIGraphicExtension + { +#if UNITY_EDITOR + // v1 No.153 + [MethodAPI] + [APIDescriptionCN("设置 Graphic 的 alpha 值 ")] + [APIDescriptionEN("set graphic's alpha value")] + [APIExampleCode(@" +var gameObject = new GameObject(); +var image = gameObject.AddComponent(); +var rawImage = gameObject.AddComponent(); + + +image.ColorAlpha(1.0f); +rawImage.ColorAlpha(1.0f); +")] +#endif + public static T ColorAlpha(this T selfGraphic, float alpha) where T : Graphic + { + var color = selfGraphic.color; + color.a = alpha; + selfGraphic.color = color; + return selfGraphic; + } + +#if UNITY_EDITOR + // v1 No.154 + [MethodAPI] + [APIDescriptionCN("设置 image 的 fillAmount 值")] + [APIDescriptionEN("set image's fillAmount value")] + [APIExampleCode(@" +var gameObject = new GameObject(); +var image1 = gameObject.AddComponent(); + +image1.FillAmount(0.0f); +")] +#endif + public static Image FillAmount(this Image selfImage, float fillAmount) + { + selfImage.fillAmount = fillAmount; + return selfImage; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs.meta new file mode 100644 index 0000000..75c04b9 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/6.UnityEngineUIGraphicExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ffdcff2f9c014047bc785723bc292477 +timeCreated: 1647508258 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs new file mode 100644 index 0000000..ba7535a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs @@ -0,0 +1,321 @@ + +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Others", 8)] + [APIDescriptionCN("其他的一些静态扩展")] + [APIDescriptionEN("other extension")] +#endif + public static class UnityEngineOthersExtension + { +#if UNITY_EDITOR + // v1 No.155 + [MethodAPI] + [APIDescriptionCN("随机 List 中的一个元素")] + [APIDescriptionEN("get random item in a list")] + [APIExampleCode(@" +new List(){ 1,2,3 }.GetRandomItem(); +")] +#endif + public static T GetRandomItem(this List list) + { + return list[UnityEngine.Random.Range(0, list.Count)]; + } + +#if UNITY_EDITOR + // v1.0.34 + [MethodAPI] + [APIDescriptionCN("随机获取并删除 List 中的一个元素")] + [APIDescriptionEN("get and remove random item in a list")] + [APIExampleCode(@" +new List(){ 1,2,3 }.GetAndRemoveRandomItem(); +")] +#endif + public static T GetAndRemoveRandomItem(this List list) + { + var randomIndex = UnityEngine.Random.Range(0, list.Count); + var randomItem = list[randomIndex]; + list.RemoveAt(randomIndex); + return randomItem; + } + +#if UNITY_EDITOR + // v1 + [MethodAPI] + [APIDescriptionCN("为 SpriteRender 设置 alpha 值")] + [APIDescriptionEN("set SpriteRender's alpha value")] + [APIExampleCode(@" +mySprRender.Alpha(0.5f); +")] +#endif + public static SpriteRenderer Alpha(this SpriteRenderer self, float alpha) + { + var color = self.color; + color.a = alpha; + self.color = color; + return self; + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("Mathf.Lerp")] + [APIDescriptionEN("Mathf.Lerp")] + [APIExampleCode(@" +var v = 0.5f.Lerp(0.1f,0.5f); +// v is 0.3f +")] +#endif + public static float Lerp(this float self, float a, float b) + { + return Mathf.Lerp(a, b, self); + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("Mathf.Abs")] + [APIDescriptionEN("Mathf.Abs")] + [APIExampleCode(@" +var absValue = -1.0f.Abs(); +// absValue is 1.0f +")] +#endif + public static float Abs(this float self) + { + return Mathf.Abs(self); + } + + public static float Abs(this int self) + { + return Mathf.Abs(self); + } + + +#if UNITY_EDITOR + // Added in v1.0.150 + [MethodAPI] + [APIDescriptionCN("Mathf.Exp")] + [APIDescriptionEN("Mathf.Exp")] + [APIExampleCode(@" +var expValue = 1.0f.Exp(); // Mathf.Exp(1.0f) +")] +#endif + public static float Exp(this float self) + { + return Mathf.Exp(self); + } + + public static float Exp(this int self) + { + return Mathf.Exp(self); + } + +#if UNITY_EDITOR + // Added in v1.0.31 + [MethodAPI] + [APIDescriptionCN("Mathf.Sign")] + [APIDescriptionEN("Mathf.Sign")] + [APIExampleCode(@" +var sign = -5.0f.Sign(); +// sign is 5.0f +")] +#endif + public static float Sign(this float self) + { + return Mathf.Sign(self); + } + + public static float Sign(this int self) + { + return Mathf.Sign(self); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Cos")] + [APIDescriptionEN("Mathf.Cos")] + [APIExampleCode(@" +var cos = (90.0f * Mathf.Deg2Rad).Cos(); +// cos is 0f +")] +#endif + public static float Cos(this float self) + { + return Mathf.Cos(self); + } + + public static float Cos(this int self) + { + return Mathf.Cos(self); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Sin")] + [APIDescriptionEN("Mathf.Sin")] + [APIExampleCode(@" +var sin = (90.0f * Mathf.Deg2Rad).Sin(); +// sin is 1f +")] +#endif + public static float Sin(this float self) + { + return Mathf.Sin(self); + } + + public static float Sin(this int self) + { + return Mathf.Sin(self); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Cos(x * Mathf.Deg2Rad)")] + [APIDescriptionEN("Mathf.Cos(x * Mathf.Deg2Rad)")] + [APIExampleCode(@" +var cos = 90.0f.CosAngle(); +// cos is 0f +")] +#endif + public static float CosAngle(this float self) + { + return Mathf.Cos(self * Mathf.Deg2Rad); + } + + public static float CosAngle(this int self) + { + return Mathf.Cos(self * Mathf.Deg2Rad); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Sin(x * Mathf.Deg2Rad)")] + [APIDescriptionEN("Mathf.Sin(x * Mathf.Deg2Rad)")] + [APIExampleCode(@" +var sin = 90.0f.SinAngle(); +// sin is 1f +")] +#endif + public static float SinAngle(this float self) + { + return Mathf.Sin(self * Mathf.Deg2Rad); + } + + public static float SinAngle(this int self) + { + return Mathf.Sin(self * Mathf.Deg2Rad); + } + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Deg2Rad")] + [APIDescriptionEN("Mathf.Deg2Rad")] + [APIExampleCode(@" +var radius = 90.0f.Deg2Rad(); +// radius is 1.57f +")] +#endif + public static float Deg2Rad(this float self) + { + return self * Mathf.Deg2Rad; + } + + public static float Deg2Rad(this int self) + { + return self * Mathf.Deg2Rad; + } + + +#if UNITY_EDITOR + // Added in v1.0.32 + [MethodAPI] + [APIDescriptionCN("Mathf.Rad2Deg")] + [APIDescriptionEN("Mathf.Rad2Deg")] + [APIExampleCode(@" +var degree = 1.57f.Rad2Deg(); +// degree is 90f +")] +#endif + public static float Rad2Deg(this float self) + { + return self * Mathf.Rad2Deg; + } + + public static float Rad2Deg(this int self) + { + return self * Mathf.Rad2Deg; + } + +#if UNITY_EDITOR + // Added in v1.0.129 + [MethodAPI] + [APIDescriptionCN("将欧拉角转换为方向向量(Vector2)")] + [APIDescriptionEN("Convert Degree To Direction(Vector2)")] + [APIExampleCode(@" +var direction = 90.AngleToDirection2D(); +// Vector2(1,0) +")] +#endif + + public static Vector2 AngleToDirection2D(this int self) + { + return new Vector2(self.CosAngle(), self.SinAngle()); + } + + public static Vector2 AngleToDirection2D(this float self) + { + return new Vector2(self.CosAngle(), self.SinAngle()); + } + +#if UNITY_EDITOR + // Added in v1.0.129 + [MethodAPI] + [APIDescriptionCN("将方向(Vector2)转换为欧拉角")] + [APIDescriptionEN("Convert Direction To Degrees")] + [APIExampleCode(@" +var direction = Vector2.right.ToAngle(); +// Vector2(1,0) +")] +#endif + public static float ToAngle(this Vector2 self) + { + return Mathf.Atan2(self.y, self.x).Rad2Deg(); + } + } + +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Random", 7)] + [APIDescriptionCN("针对随机做的一些封装")] + [APIDescriptionEN("wrapper for random")] +#endif + public static class RandomUtility + { +#if UNITY_EDITOR + // v1 + [MethodAPI] + [APIDescriptionCN("随机选择")] + [APIDescriptionEN("RandomChoose")] + [APIExampleCode(@" +var result = RandomUtility.Choose(1,1,1,2,2,2,2,3,3); + +if (result == 3) +{ + // todo ... +} +")] +#endif + public static T Choose(params T[] args) + { + return args[UnityEngine.Random.Range(0, args.Length)]; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs.meta new file mode 100644 index 0000000..1f4ce85 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/7.UnityEngineOthersExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 095d03eec50f4f77828198360c9193d3 +timeCreated: 1647508997 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs new file mode 100644 index 0000000..bfc5656 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs @@ -0,0 +1,313 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.Vector2/3", 8)] + [APIDescriptionCN("针对 Vector2/Vector3 封装的函数")] + [APIDescriptionEN("wrapper function for Vector2/Vector3")] + [APIExampleCode(@" + gameObjA.DirectionFrom(gameObjB); + myComponentA.DirectionFrom(gameObjB); + gameObjA.DirectionFrom(myComponentB); + myComponentA.DirectionFrom(myComponentB); + + // also support DirectionTo/ NormalizedDirectionFrom /NormalizedDirectionTo +")] +#endif + public static class UnityEngineVectorExtension + { + #if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("to.transform.position - self.transform.position")] + [APIDescriptionEN("to.transform.position - self.transform.position")] + [APIExampleCode(@" +gameObj/otherComponent.DirectionTo(otherGameObj/otherComponent) +")] +#endif + public static Vector3 DirectionTo(this Component self, Component to) => + to.transform.position - self.transform.position; + + public static Vector3 DirectionTo(this GameObject self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector3 DirectionTo(this Component self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector3 DirectionTo(this GameObject self, Component to) => + to.transform.position - self.transform.position; + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("self.transform.position - from.transform.position")] + [APIDescriptionEN("self.transform.position - from.transform.position")] + [APIExampleCode(@" +gameObj/otherComponent.DirectionFrom(otherGameObj/otherComponent) +")] +#endif + public static Vector3 DirectionFrom(this Component self, Component from) => + self.transform.position - from.transform.position; + + public static Vector3 DirectionFrom(this GameObject self, GameObject from) => + self.transform.position - from.transform.position; + + public static Vector3 DirectionFrom(this GameObject self, Component from) => + self.transform.position - from.transform.position; + + public static Vector3 DirectionFrom(this Component self, GameObject from) => + self.transform.position - from.transform.position; + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(to.transform.position - self.transform.position).normalized")] + [APIDescriptionEN("(to.transform.position - self.transform.position).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirectionTo(otherGameObj/otherComponent) +")] +#endif + public static Vector3 NormalizedDirectionTo(this Component self, Component to) => + self.DirectionTo(to).normalized; + + public static Vector3 NormalizedDirectionTo(this GameObject self, GameObject to) => + self.DirectionTo(to).normalized; + + public static Vector3 NormalizedDirectionTo(this Component self, GameObject to) => + self.DirectionTo(to).normalized; + + public static Vector3 NormalizedDirectionTo(this GameObject self, Component to) => + self.DirectionTo(to).normalized; + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(self.transform.position - from.transform.position).normalized")] + [APIDescriptionEN("(self.transform.position - from.transform.position).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirectionTo(otherGameObj/otherComponent) +")] +#endif + public static Vector3 NormalizedDirectionFrom(this Component self, Component from) => + self.DirectionFrom(from).normalized; + + public static Vector3 NormalizedDirectionFrom(this GameObject self, GameObject from) => + self.DirectionFrom(from).normalized; + + public static Vector3 NormalizedDirectionFrom(this GameObject self, Component from) => + self.DirectionFrom(from).normalized; + + public static Vector3 NormalizedDirectionFrom(this Component self, GameObject from) => + self.DirectionFrom(from).normalized; + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(Vector2)(to.transform.position - self.transform.position)")] + [APIDescriptionEN("(Vector2)(to.transform.position - self.transform.position)")] + [APIExampleCode(@" +gameObj/otherComponent.Direction2DTo(otherGameObj/otherComponent) +")] +#endif + public static Vector2 Direction2DTo(this Component self, Component to) => + to.transform.position - self.transform.position; + + public static Vector2 Direction2DTo(this GameObject self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector2 Direction2DTo(this Component self, GameObject to) => + to.transform.position - self.transform.position; + + public static Vector2 Direction2DTo(this GameObject self, Component to) => + to.transform.position - self.transform.position; + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("(Vector2)(self.transform.position - from.transform.position)")] + [APIDescriptionEN("(Vector2)(self.transform.position - from.transform.position)")] + [APIExampleCode(@" +gameObj/otherComponent.Direction2DFrom(otherGameObj/otherComponent) +")] +#endif + public static Vector2 Direction2DFrom(this Component self, Component from) => + self.transform.position - from.transform.position; + + public static Vector2 Direction2DFrom(this GameObject self, GameObject from) => + self.transform.position - from.transform.position; + + public static Vector2 Direction2DFrom(this GameObject self, Component from) => + self.transform.position - from.transform.position; + + public static Vector2 Direction2DFrom(this Component self, GameObject from) => + self.transform.position - from.transform.position; + + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("((Vector2)(to.transform.position - self.transform.position)).normalized")] + [APIDescriptionEN("((Vector2)(to.transform.position - self.transform.position)).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirection2DTo(otherGameObj/otherComponent) +")] +#endif + public static Vector2 NormalizedDirection2DTo(this Component self, Component to) => + self.Direction2DTo(to).normalized; + + public static Vector2 NormalizedDirection2DTo(this GameObject self, GameObject to) => + self.Direction2DTo(to).normalized; + + public static Vector2 NormalizedDirection2DTo(this Component self, GameObject to) => + self.Direction2DTo(to).normalized; + + public static Vector2 NormalizedDirection2DTo(this GameObject self, Component to) => + self.Direction2DTo(to).normalized; + + +#if UNITY_EDITOR + // v1.0.79 + [MethodAPI] + [APIDescriptionCN("((Vector2)(self.transform.position - from.transform.position)).normalized")] + [APIDescriptionEN("((Vector2)(self.transform.position - from.transform.position)).normalized")] + [APIExampleCode(@" +gameObj/otherComponent.NormalizedDirection2DFrom(otherGameObj/otherComponent) +")] +#endif + public static Vector2 NormalizedDirection2DFrom(this Component self, Component from) => + self.Direction2DFrom(from).normalized; + + public static Vector2 NormalizedDirection2DFrom(this GameObject self, GameObject from) => + self.Direction2DFrom(from).normalized; + + public static Vector2 NormalizedDirection2DFrom(this GameObject self, Component from) => + self.Direction2DFrom(from).normalized; + + public static Vector2 NormalizedDirection2DFrom(this Component self, GameObject from) => + self.Direction2DFrom(from).normalized; + + + public static Vector2 ToVector2(this Vector3 self) => new Vector2(self.x, self.y); + + public static Vector3 ToVector3(this Vector2 self, float z = 0) + { + return new Vector3(self.x, self.y, z); + } + + public static Vector3 X(this Vector3 self,float x) + { + self.x = x; + return self; + } + + public static Vector3 Y(this Vector3 self,float y) + { + self.y = y; + return self; + } + + public static Vector3 Z(this Vector3 self,float z) + { + self.z = z; + return self; + } + + + public static Vector2 X(this Vector2 self,float x) + { + self.x = x; + return self; + } + + public static Vector2 Y(this Vector2 self,float y) + { + self.y = y; + return self; + } + + public static float Distance(this GameObject self, GameObject other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance(this Component self, GameObject other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance(this GameObject self, Component other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance(this Component self, Component other) + { + return Vector3.Distance(self.Position(), other.Position()); + } + + public static float Distance2D(this GameObject self, GameObject other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float Distance2D(this Component self, GameObject other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float Distance2D(this GameObject self, Component other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float Distance2D(this Component self, Component other) + { + return Vector2.Distance(self.Position2D(), other.Position2D()); + } + + public static float LocalDistance(this GameObject self, GameObject other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance(this Component self, GameObject other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance(this GameObject self, Component other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance(this Component self, Component other) + { + return Vector3.Distance(self.LocalPosition(), other.LocalPosition()); + } + + public static float LocalDistance2D(this GameObject self, GameObject other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + + public static float LocalDistance2D(this Component self, GameObject other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + + public static float LocalDistance2D(this GameObject self, Component other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + + public static float LocalDistance2D(this Component self, Component other) + { + return Vector2.Distance(self.LocalPosition2D(), other.LocalPosition2D()); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs.meta new file mode 100644 index 0000000..d85086e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/8.UnityEngineVectorExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fb2654f2feb44ad6b264c2d6a8c8a2de +timeCreated: 1693400243 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs new file mode 100644 index 0000000..d284f23 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs @@ -0,0 +1,30 @@ + +using UnityEngine; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("00.FluentAPI.Unity", "UnityEngine.RectTransform", 9)] + [APIDescriptionCN("针对 RectTransform 封装的函数")] + [APIDescriptionEN("wrapper function for RectTransform")] +#endif + public static class UnityEngineRectTransformExtension + { +#if UNITY_EDITOR + // v1.0.167 + [MethodAPI] + [APIDescriptionCN("设置 rectTransform.anchoredPosition.y 值")] + [APIDescriptionEN("set rectTransform.anchoredPosition.y value")] + [APIExampleCode(@" +text.rectTransform.AnchoredPositionY(5); +")] +#endif + public static RectTransform AnchoredPositionY(this RectTransform selfRectTrans, float anchoredPositionY) + { + var anchorPos = selfRectTrans.anchoredPosition; + anchorPos.y = anchoredPositionY; + selfRectTrans.anchoredPosition = anchorPos; + return selfRectTrans; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs.meta new file mode 100644 index 0000000..3558559 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/0.Unity/9.UnityEngineRectTransformExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 76b337d0ece04cab994eb2f50c6bd9aa +timeCreated: 1733116027 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp.meta new file mode 100644 index 0000000..69ccaef --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 820be0af14a349f38700b599aa5252e3 +timeCreated: 1647422394 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs new file mode 100644 index 0000000..befd2c4 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs @@ -0,0 +1,103 @@ + +using System; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.Object", 0)] + [APIDescriptionCN("针对 System.Object 提供的链式扩展,理论上任何对象都可以使用")] + [APIDescriptionEN("The chain extension provided by System.object can theoretically be used by any Object")] +#endif + public static class SystemObjectExtension + { +#if UNITY_EDITOR + // v1 No.1 + [MethodAPI] + [APIDescriptionCN("将自己传到 Action 委托中")] + [APIDescriptionEN("apply self to the Action delegate")] + [APIExampleCode(@" +new GameObject() + .Self(gameObj=>gameObj.name = ""Enemy"") + .Self(gameObj=>{ + Debug.Log(gameObj.name); + });" + )] +#endif + public static T Self(this T self, Action onDo) + { + onDo?.Invoke(self); + return self; + } + +#if UNITY_EDITOR + // v1 No.1.1 + [MethodAPI] + [APIDescriptionCN("将自己传到 Func 委托中,然后返回自己")] + [APIDescriptionEN("apply self to the Func delegate")] + [APIExampleCode(@" +new GameObject() + .Self(gameObj=>gameObj.name = ""Enemy"") + .Self(gameObj=>{ + Debug.Log(gameObj.name); + });" + )] +#endif + public static T Self(this T self, Func onDo) + { + return onDo.Invoke(self); + } + + +#if UNITY_EDITOR + // v1 No.2 + [MethodAPI] + [APIDescriptionCN("判断是否为空")] + [APIDescriptionEN("Check Is Null,return true or false")] + [APIExampleCode(@" +var simpleObject = new object(); + +if (simpleObject.IsNull()) // simpleObject == null +{ + // do sth +}")] +#endif + public static bool IsNull(this T selfObj) where T : class + { + return null == selfObj; + } + +#if UNITY_EDITOR + // v1 No.3 + [MethodAPI] + [APIDescriptionCN("判断不是为空")] + [APIDescriptionEN("Check Is Not Null,return true or false")] + [APIExampleCode(@" +var simpleObject = new object(); + +if (simpleObject.IsNotNull()) // simpleObject != null +{ + // do sth +}")] +#endif + public static bool IsNotNull(this T selfObj) where T : class + { + return null != selfObj; + } + +#if UNITY_EDITOR + // v1 No.36 + [MethodAPI] + [APIDescriptionCN("转型")] + [APIDescriptionEN("cast")] + [APIExampleCode(@" +int a = 10; +Debug.Log(a.As()) +// 10 +")] +#endif + public static T As(this object selfObj) where T : class + { + return selfObj as T; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs.meta new file mode 100644 index 0000000..73db8e8 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/0.SystemObjectExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8ef786a6b2b044b69fcc6abb9e695619 +timeCreated: 1647422404 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs new file mode 100644 index 0000000..5570ca5 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs @@ -0,0 +1,275 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.String", 1)] + [APIDescriptionCN("针对 System.String 提供的链式扩展,理论上任何集合都可以使用")] + [APIDescriptionEN("The chain extension provided by System.Collections can theoretically be used by any collection")] +#endif + public static class SystemStringExtension + { +#if UNITY_EDITOR + // v1 No.18 + [MethodAPI] + [APIDescriptionCN("检测是否为空或 Empty")] + [APIDescriptionEN("Check Whether string is null or empty")] + [APIExampleCode(@" +Debug.Log(string.Empty.IsNullOrEmpty()); +// true + ")] +#endif + public static bool IsNullOrEmpty(this string selfStr) + { + return string.IsNullOrEmpty(selfStr); + } + + +#if UNITY_EDITOR + // v1 No.19 + [MethodAPI] + [APIDescriptionCN("检测是否为非空且非Empty")] + [APIDescriptionEN("Checks both not null and non-empty")] + [APIExampleCode(@" +Debug.Log(""Hello"".IsNotNullAndEmpty()); +// true + ")] +#endif + public static bool IsNotNullAndEmpty(this string selfStr) + { + return !string.IsNullOrEmpty(selfStr); + } + +#if UNITY_EDITOR + // v1 No.20 + [MethodAPI] + [APIDescriptionCN("去掉两端空格后,检测是否为空或 Empty")] + [APIDescriptionEN("Check if it is Empty or Empty after removing whitespace from both sides")] + [APIExampleCode(@" +Debug.Log("" "".IsTrimNullOrEmpty()); +// true + ")] +#endif + public static bool IsTrimNullOrEmpty(this string selfStr) + { + return selfStr == null || string.IsNullOrEmpty(selfStr.Trim()); + } + + /// + /// Check Whether string trim is null or empty + /// + /// + /// +#if UNITY_EDITOR + // v1 No.21 + [MethodAPI] + [APIDescriptionCN("去掉两端空格后,检测是否为非 null 且非 Empty")] + [APIDescriptionEN("After removing whitespace from both sides, check whether it is non-null and non-empty")] + [APIExampleCode(@" +Debug.Log("" 123 "".IsTrimNotNullAndEmpty()); +// true + ")] +#endif + public static bool IsTrimNotNullAndEmpty(this string selfStr) + { + return selfStr != null && !string.IsNullOrEmpty(selfStr.Trim()); + } + + + /// + /// 缓存 + /// + private static readonly char[] mCachedSplitCharArray = { '.' }; + +#if UNITY_EDITOR + // v1 No.22 + [MethodAPI] + [APIDescriptionCN("字符串分割")] + [APIDescriptionEN("String splitting")] + [APIExampleCode(@" +""1.2.3.4.5"".Split('.').ForEach(str=>Debug.Log(str)); +// 1 2 3 4 5 + ")] +#endif + public static string[] Split(this string selfStr, char splitSymbol) + { + mCachedSplitCharArray[0] = splitSymbol; + return selfStr.Split(mCachedSplitCharArray); + } + +#if UNITY_EDITOR + // v1 No.23 + [MethodAPI] + [APIDescriptionCN("格式化字符串填充参数")] + [APIDescriptionEN("The format string populates the parameters")] + [APIExampleCode(@" + +var newStr = ""{0},{1}"".FillFormat(1,2); +Debug.Log(newStr); +// 1,2 + ")] +#endif + public static string FillFormat(this string selfStr, params object[] args) + { + return string.Format(selfStr, args); + } + +#if UNITY_EDITOR + // v1 No.24 + [MethodAPI] + [APIDescriptionCN("返回包含此字符串的 StringBuilder")] + [APIDescriptionEN("Returns a StringBuilder containing this string")] + [APIExampleCode(@" +var builder = ""Hello"".Builder(); +builder.Append("" QF""); +Debug.Log(builder.ToString()); +// Hello QF + ")] +#endif + public static StringBuilder Builder(this string selfStr) + { + return new StringBuilder(selfStr); + } + +#if UNITY_EDITOR + // v1 No.25 + [MethodAPI] + [APIDescriptionCN("StringBuilder 添加前缀")] + [APIDescriptionEN("StringBuilder insert prefix string")] + [APIExampleCode(@" +var builder = ""I'm liangxie"".Builder().AddPrefix(""Hi!"") ; +Debug.Log(builder.ToString()); +// Hi!I'm liangxie + ")] +#endif + public static StringBuilder AddPrefix(this StringBuilder self, string prefixString) + { + self.Insert(0, prefixString); + return self; + } + + +#if UNITY_EDITOR + // v1 No.26 + [MethodAPI] + [APIDescriptionCN("字符串解析成 Int")] + [APIDescriptionEN("parse string to int")] + [APIExampleCode(@" +var number = ""123456"".ToInt(); +Debug.Log(number); +// 123456 +// notice unsafe +// 不安全 + ")] +#endif + public static int ToInt(this string selfStr, int defaulValue = 0) + { + var retValue = defaulValue; + return int.TryParse(selfStr, out retValue) ? retValue : defaulValue; + } + + public static long ToLong(this string self, long defaultValue = 0) + { + var retValue = defaultValue; + return long.TryParse(self, out retValue) ? retValue : defaultValue; + } + +#if UNITY_EDITOR + // v1 No.27 + [MethodAPI] + [APIDescriptionCN("字符串解析成 Int")] + [APIDescriptionEN("parse string to int")] + [APIExampleCode(@" +DateTime.Now.ToString().ToDataTime(); + ")] +#endif + public static DateTime ToDateTime(this string selfStr, DateTime defaultValue = default(DateTime)) + { + return DateTime.TryParse(selfStr, out var retValue) ? retValue : defaultValue; + } + + +#if UNITY_EDITOR + // v1 No.28 + [MethodAPI] + [APIDescriptionCN("字符串解析成 float")] + [APIDescriptionEN("parse string to float")] + [APIExampleCode(@" +var number = ""123456f"".ToInt(); +Debug.Log(number); +// 123456 +// notice unsafe +// 不安全 + ")] +#endif + public static float ToFloat(this string selfStr, float defaultValue = 0) + { + return float.TryParse(selfStr, out var retValue) ? retValue : defaultValue; + } + +#if UNITY_EDITOR + // v1 No.29 + [MethodAPI] + [APIDescriptionCN("是否存在中文字符")] + [APIDescriptionEN("check string contains chinese or not")] + [APIExampleCode(@" +Debug.Log(""你好"".HasChinese()); +// true +")] +#endif + public static bool HasChinese(this string input) + { + return Regex.IsMatch(input, @"[\u4e00-\u9fa5]"); + } + +#if UNITY_EDITOR + // v1 No.30 + [MethodAPI] + [APIDescriptionCN("是否存在空格")] + [APIDescriptionEN("check string contains space or not")] + [APIExampleCode(@" +Debug.Log(""你好 "".HasSpace()); +// true +")] +#endif + public static bool HasSpace(this string input) + { + return input.Contains(" "); + } + +#if UNITY_EDITOR + // v1 No.31 + [MethodAPI] + [APIDescriptionCN("remove string")] + [APIDescriptionEN("check string contains space or not")] + [APIExampleCode(@" +Debug.Log(""Hello World "".RemoveString(""Hello"","" "")); +// World +")] +#endif + public static string RemoveString(this string str, params string[] targets) + { + return targets.Aggregate(str, (current, t) => current.Replace(t, string.Empty)); + } + +#if UNITY_EDITOR + // v1.0.39 + [MethodAPI] + [APIDescriptionCN("join string")] + [APIDescriptionEN("join string")] + [APIExampleCode(@" +Debug.Log(new List() { ""1"",""2"",""3""}.StringJoin("","")); +// 1,2,3 +")] +#endif + public static string StringJoin(this IEnumerable self, string separator) + { + return string.Join(separator, self); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs.meta new file mode 100644 index 0000000..eba9f9d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/1.SystemStringExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 16f9643181cd400085f8615855718a05 +timeCreated: 1647445231 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs new file mode 100644 index 0000000..1dac716 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs @@ -0,0 +1,183 @@ + +using System.IO; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.IO", 2)] + [APIDescriptionCN("针对 System.IO 提供的链式扩展,主要是文件和文件夹的一些 IO 操作")] + [APIDescriptionEN("IO chain extension for system. IO, mainly file and folder IO operations")] +#endif + public static class SystemIOExtension + { +#if UNITY_EDITOR + // v1 No.10 + [MethodAPI] + [APIDescriptionCN("创建文件夹,如果存在则不创建")] + [APIDescriptionEN("Create folder or not if it exists")] + [APIExampleCode(@" +var testDir = ""Assets/TestFolder""; +testDir.CreateDirIfNotExists();" + )] +#endif + public static string CreateDirIfNotExists(this string dirFullPath) + { + if (!Directory.Exists(dirFullPath)) + { + Directory.CreateDirectory(dirFullPath); + } + + return dirFullPath; + } + +#if UNITY_EDITOR + // v1 No.11 + [MethodAPI] + [APIDescriptionCN("删除文件夹,如果存在")] + [APIDescriptionEN("Delete the folder if it exists")] + [APIExampleCode(@" +var testDir =""Assets/TestFolder""; +testDir.DeleteDirIfExists(); + ")] +#endif + public static void DeleteDirIfExists(this string dirFullPath) + { + if (Directory.Exists(dirFullPath)) + { + Directory.Delete(dirFullPath, true); + } + } + +#if UNITY_EDITOR + // v1 No.12 + [MethodAPI] + [APIDescriptionCN("清空 Dir(保留目录),如果存在")] + [APIDescriptionEN("Clear Dir (reserved directory), if exists")] + [APIExampleCode(@" +var testDir = ""Assets/TestFolder""; +testDir.EmptyDirIfExists(); + ")] +#endif + public static void EmptyDirIfExists(this string dirFullPath) + { + if (Directory.Exists(dirFullPath)) + { + Directory.Delete(dirFullPath, true); + } + + Directory.CreateDirectory(dirFullPath); + } + +#if UNITY_EDITOR + // v1 No.13 + [MethodAPI] + [APIDescriptionCN("删除文件 如果存在")] + [APIDescriptionEN("Delete the file if it exists")] + [APIExampleCode(@" +var filePath = ""Assets/Test.txt""; +File.Create(""Assets/Test""); +filePath.DeleteFileIfExists(); + ")] +#endif + public static bool DeleteFileIfExists(this string fileFullPath) + { + if (File.Exists(fileFullPath)) + { + File.Delete(fileFullPath); + return true; + } + + return false; + } + + +#if UNITY_EDITOR + // v1 No.14 + [MethodAPI] + [APIDescriptionCN("合并路径")] + [APIDescriptionEN("Combine path")] + [APIExampleCode(@" +var path = Application.dataPath.CombinePath(""Resources""); +Debug.Log(Path) +// projectPath/Assets/Resources + ")] +#endif + public static string CombinePath(this string selfPath, string toCombinePath) + { + return Path.Combine(selfPath, toCombinePath); + } + + +#if UNITY_EDITOR + // v1 No.15 + [MethodAPI] + [APIDescriptionCN("根据路径获取文件名")] + [APIDescriptionEN("get file name by path")] + [APIExampleCode(@" +var fileName =""/abc/def/b.txt"".GetFileName(); +Debug.Log(fileName0); +// b.txt + ")] +#endif + public static string GetFileName(this string filePath) + { + return Path.GetFileName(filePath); + } + +#if UNITY_EDITOR + // v1 No.16 + [MethodAPI] + [APIDescriptionCN("根据路径获取文件名,不包含文件扩展名")] + [APIDescriptionEN("Get the file name based on the path, excluding the file name extension")] + [APIExampleCode(@" +var fileName =""/abc/def/b.txt"".GetFileNameWithoutExtend(); +Debug.Log(fileName0); +// b + ")] +#endif + + public static string GetFileNameWithoutExtend(this string filePath) + { + return Path.GetFileNameWithoutExtension(filePath); + } + +#if UNITY_EDITOR + // v1 No.17 + [MethodAPI] + [APIDescriptionCN("根据路径获取文件扩展名")] + [APIDescriptionEN("Get the file extension based on the path")] + [APIExampleCode(@" +var fileName =""/abc/def/b.txt"".GetFileExtendName(); +Debug.Log(fileName0); +// .txt + ")] +#endif + public static string GetFileExtendName(this string filePath) + { + return Path.GetExtension(filePath); + } + + +#if UNITY_EDITOR + // v1 No.156 + [MethodAPI] + [APIDescriptionCN("获取文件夹路径")] + [APIDescriptionEN("get filePath's folder path")] + [APIExampleCode(@" +var folderPath =""/abc/def/b.txt"".GetFolderPath(); +Debug.Log(fileName0); +// /abs/def + ")] +#endif + public static string GetFolderPath(this string path) + { + if (string.IsNullOrEmpty(path)) + { + return string.Empty; + } + + return Path.GetDirectoryName(path); + } + + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs.meta new file mode 100644 index 0000000..d682024 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/2.SystemIOExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 214fbbb4fd6f426f8e9867263025a775 +timeCreated: 1647438572 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs new file mode 100644 index 0000000..a756073 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs @@ -0,0 +1,188 @@ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.Collections", 3)] + [APIDescriptionCN("针对 System.Collections 提供的链式扩展,理论上任何集合都可以使用")] + [APIDescriptionEN("The chain extension provided by System.Collections can theoretically be used by any collection")] +#endif + public static class CollectionsExtension + { +#if UNITY_EDITOR + // v1 No.4 + [MethodAPI] + [APIDescriptionCN("遍历 IEnumerable")] + [APIDescriptionEN("ForEach for IEnumerable")] + [APIExampleCode(@" +IEnumerable testIEnumerable = new List { 1, 2, 3 }; +testIEnumerable.ForEach(number => Debug.Log(number)); +// output +// 1 +// 2 +// 3 +new Dictionary() +{ + {""name"",""liangxie""}, + {""company"",""liangxiegame"" } +} +.ForEach(keyValue => Debug.LogFormat(""key:{0},value:{1}"", keyValue.Key, keyValue.Value)); +// key:name,value:liangxie +// key:company,value:liangxiegame")] +#endif + public static IEnumerable ForEach(this IEnumerable self, Action action) + { + foreach (var item in self) + { + action(item); + } + + return self; + } + +#if UNITY_EDITOR + // v1 No.5 + [MethodAPI] + [APIDescriptionCN("List 倒序遍历")] + [APIDescriptionEN("Reverse ForEach for List")] + [APIExampleCode(@" +var testList = new List { 1, 2, 3 }; +testList.ForEachReverse(number => number.LogInfo()); +// 3 2 1 +")] +#endif + public static List ForEachReverse(this List selfList, Action action) + { + for (var i = selfList.Count - 1; i >= 0; --i) + action(selfList[i]); + + return selfList; + } + + +#if UNITY_EDITOR + // v1 No.6 + [MethodAPI] + [APIDescriptionCN("遍历 List (可获得索引)")] + [APIDescriptionEN("foreach List (can get index)")] + [APIExampleCode(@" +var testList = new List {""a"", ""b"", ""c"" }; +testList.Foreach((c,index)=>Debug.Log(index)); +// 1, 2, 3, +")] +#endif + public static void ForEach(this List list, Action action) + { + for (var i = 0; i < list.Count; i++) + { + action(i, list[i]); + } + } + + +#if UNITY_EDITOR + // v1 No.7 + [MethodAPI] + [APIDescriptionCN("遍历字典")] + [APIDescriptionEN("ForEach Dictionary")] + [APIExampleCode(@" +var infos = new Dictionary {{""name"",""liangxie""},{""age"",""18""}}; +infos.ForEach((key,value)=> Debug.LogFormat(""{0}:{1}"",key,value); +// name:liangxie +// age:18 +")] +#endif + public static void ForEach(this Dictionary dict, Action action) + { + var dictE = dict.GetEnumerator(); + + while (dictE.MoveNext()) + { + var current = dictE.Current; + action(current.Key, current.Value); + } + + dictE.Dispose(); + } + + +#if UNITY_EDITOR + // v1 No.8 + [MethodAPI] + [APIDescriptionCN("合并字典")] + [APIDescriptionEN("Merge Dictionaries")] + [APIExampleCode(@" +var dictionary1 = new Dictionary { { ""1"", ""2"" } }; +var dictionary2 = new Dictionary { { ""3"", ""4"" } }; +var dictionary3 = dictionary1.Merge(dictionary2); +dictionary3.ForEach(pair => Debug.LogFormat(""{0}:{1}"", pair.Key, pair.Value)); +// 1:2 +// 3:4 + +// notice: duplicate keys are not supported. +// 注意:不支持重复的 key。 +")] +#endif + public static Dictionary Merge(this Dictionary dictionary, + params Dictionary[] dictionaries) + { + return dictionaries.Aggregate(dictionary, + (current, dict) => current.Union(dict).ToDictionary(kv => kv.Key, kv => kv.Value)); + } + +#if UNITY_EDITOR + // v1 No.9 + [MethodAPI] + [APIDescriptionCN("字典添加新的字典")] + [APIDescriptionEN("Dictionary Adds a new dictionary")] + [APIExampleCode(@" +var dictionary1 = new Dictionary { { ""1"", ""2"" } }; +var dictionary2 = new Dictionary { { ""1"", ""4"" } }; +var dictionary3 = dictionary1.AddRange(dictionary2,true); // true means override +dictionary3.ForEach(pair => Debug.LogFormat(""{0}:{1}"", pair.Key, pair.Value)); +// 1:2 +// 3:4 + +// notice: duplicate keys are supported. +// 注意:支持重复的 key。 +")] +#endif + public static void AddRange(this Dictionary dict, Dictionary addInDict, + bool isOverride = false) + { + var enumerator = addInDict.GetEnumerator(); + + while (enumerator.MoveNext()) + { + var current = enumerator.Current; + if (dict.ContainsKey(current.Key)) + { + if (isOverride) + dict[current.Key] = current.Value; + continue; + } + + dict.Add(current.Key, current.Value); + } + + enumerator.Dispose(); + } + + + // TODO: + public static bool IsNullOrEmpty(this T[] collection) => collection == null || collection.Length == 0; + // TODO: + public static bool IsNullOrEmpty(this IList collection) => collection == null || collection.Count == 0; + // TODO: + public static bool IsNullOrEmpty(this IEnumerable collection) => collection == null || !collection.Any(); + // TODO: + public static bool IsNotNullAndEmpty(this T[] collection) => !IsNullOrEmpty(collection); + // TODO: + public static bool IsNotNullAndEmpty(this IList collection) => !IsNullOrEmpty(collection); + // TODO: + public static bool IsNotNullAndEmpty(this IEnumerable collection) => !IsNullOrEmpty(collection); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs.meta new file mode 100644 index 0000000..e0c8be6 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/3.SystemCollectionsExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b1be94df70e04fbf880352766fa84326 +timeCreated: 1647436071 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs new file mode 100644 index 0000000..2d2966e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs @@ -0,0 +1,300 @@ + + +using System; +using System.Linq; +using System.Reflection; + +namespace Stary.Evo +{ +#if UNITY_EDITOR + [ClassAPI("01.FluentAPI.CSharp", "System.Reflection", 4)] + [APIDescriptionCN("针对 System.Reflection 提供的链式扩展")] + [APIDescriptionEN("Chain extension provided for System.Reflection")] +#endif + public static class SystemReflectionExtension + { + // [UnityEditor.MenuItem("QF/Test")] + // public static void Test() + // { + // "/abc/e.txt".GetFileExtendName().LogInfo(); + // } + +#if UNITY_EDITOR + [MethodAPI] + [APIDescriptionCN("通过 Type 创建 Instance")] + [APIDescriptionEN("Create Instance By Type")] + [APIExampleCode(@" + +interface IA +{ + +} + +class A +{ +} + +IA a = typeof(A).CreateInstance(); + +")] +#endif + public static T CreateInstance(this Type self) where T : class + { + // 获取构造函数 + var constructorInfos = self.GetConstructors(BindingFlags.Instance | BindingFlags.Public); + + // 获取无参构造函数 + var ctor = Array.Find(constructorInfos, c => c.GetParameters().Length == 0); + + return ctor.Invoke(null) as T; + } + + +#if UNITY_EDITOR + // v1 No.32 + [MethodAPI] + [APIDescriptionCN("通过反射的方式调用私有方法")] + [APIDescriptionEN("call private method by reflection")] + [APIExampleCode(@" +class A +{ + private void Say() { Debug.Log(""I'm A!"") } +} + +new A().ReflectionCallPrivateMethod(""Say""); +// I'm A! +")] +#endif + public static object ReflectionCallPrivateMethod(this T self, string methodName, params object[] args) + { + var type = typeof(T); + var methodInfo = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic); + + return methodInfo?.Invoke(self, args); + } + +#if UNITY_EDITOR + // v1 No.33 + [MethodAPI] + [APIDescriptionCN("通过反射的方式调用私有方法,有返回值")] + [APIDescriptionEN("call private method by reflection,return the result")] + [APIExampleCode(@" +class A +{ + private bool Add(int a,int b) { return a + b; } +} + +Debug.Log(new A().ReflectionCallPrivateMethod(""Add"",1,2)); +// 3 +")] +#endif + public static TReturnType ReflectionCallPrivateMethod(this T self, string methodName, + params object[] args) + { + return (TReturnType)self.ReflectionCallPrivateMethod(methodName, args); + } + + +#if UNITY_EDITOR + // v1 No.34 + [MethodAPI] + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] + [APIExampleCode(@" +[DisplayName(""A Class"") +class A +{ + [DisplayName(""A Number"") + public int Number; + + [DisplayName(""Is Complete?"") + private bool Complete => Number > 100; + + [DisplayName(""Say complete result?"") + public void SayComplete() + { + Debug.Log(Complete); + } +} + +var aType = typeof(A); +// +Debug.Log(aType.HasAttribute(typeof(DisplayNameAttribute)); +// true +Debug.Log(aType.HasAttribute()); +// true + +// also support MethodInfo、PropertyInfo、FieldInfo +// 同时 也支持 MethodInfo、PropertyInfo、FieldInfo +")] +#endif + public static bool HasAttribute(this Type type, bool inherit = false) where T : Attribute + { + return type.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this Type type, Type attributeType, bool inherit = false) + { + return type.GetCustomAttributes(attributeType, inherit).Any(); + } +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this PropertyInfo prop, bool inherit = false) where T : Attribute + { + return prop.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this PropertyInfo prop, Type attributeType, bool inherit = false) + { + return prop.GetCustomAttributes(attributeType, inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this FieldInfo field, bool inherit = false) where T : Attribute + { + return field.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this FieldInfo field, Type attributeType, bool inherit) + { + return field.GetCustomAttributes(attributeType, inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this MethodInfo method, bool inherit = false) where T : Attribute + { + return method.GetCustomAttributes(typeof(T), inherit).Any(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("检查是否有指定的 Attribute")] + [APIDescriptionEN("Check whether the specified Attribute exists")] +#endif + public static bool HasAttribute(this MethodInfo method, Type attributeType, bool inherit = false) + { + return method.GetCustomAttributes(attributeType, inherit).Any(); + } + + +#if UNITY_EDITOR + // v1 No.35 + [MethodAPI] + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] + [APIExampleCode(@" +[DisplayName(""A Class"") +class A +{ + [DisplayName(""A Number"") + public int Number; + + [DisplayName(""Is Complete?"") + private bool Complete => Number > 100; + + [DisplayName(""Say complete result?"") + public void SayComplete() + { + Debug.Log(Complete); + } +} + +var aType = typeof(A); +// +Debug.Log(aType.GetAttribute(typeof(DisplayNameAttribute)); +// DisplayNameAttribute +Debug.Log(aType.GetAttribute()); +// DisplayNameAttribute + +// also support MethodInfo、PropertyInfo、FieldInfo +// 同时 也支持 MethodInfo、PropertyInfo、FieldInfo +")] +#endif + public static T GetAttribute(this Type type, bool inherit = false) where T : Attribute + { + return type.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this Type type, Type attributeType, bool inherit = false) + { + return type.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static T GetAttribute(this MethodInfo method, bool inherit = false) where T : Attribute + { + return method.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this MethodInfo method, Type attributeType, bool inherit = false) + { + return method.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static T GetAttribute(this FieldInfo field, bool inherit = false) where T : Attribute + { + return field.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this FieldInfo field, Type attributeType, bool inherit = false) + { + return field.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static T GetAttribute(this PropertyInfo prop, bool inherit = false) where T : Attribute + { + return prop.GetCustomAttributes(inherit).FirstOrDefault(); + } + +#if UNITY_EDITOR + [APIDescriptionCN("获取指定的 Attribute")] + [APIDescriptionEN("Gets the specified Attribute")] +#endif + public static object GetAttribute(this PropertyInfo prop, Type attributeType, bool inherit = false) + { + return prop.GetCustomAttributes(attributeType, inherit).FirstOrDefault(); + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs.meta new file mode 100644 index 0000000..1d3a5ba --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/FluentAPI/1.CSharp/4.SystemReflectionExtension.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4ad1fb17a7ff4016be06cd22911d23f9 +timeCreated: 1647484400 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/HashMap.cs b/Assets/00.StaryEvoTools/Runtime/Tool/HashMap.cs new file mode 100644 index 0000000..610dc7d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/HashMap.cs @@ -0,0 +1,178 @@ +using System.Collections.Generic; +using System; +using System.Collections; +using System.Linq; + +public class HashMap : IDictionary, IEnumerable +{ + Dictionary HashMapData = new Dictionary(); + public TValue this[TKey key] + { + get + { + return HashMapData[key]; + } + + set + { + if (HashMapData.ContainsKey(key)) + { + HashMapData[key] = value; + } + else + { + HashMapData.Add(key, value); + } + } + } + + public int Count + { + get + { + return HashMapData.Count; + } + } + + //如果 true 是只读的,则为 IDictionary;否则为 false。 在 Dictionary 的默认实现中,此属性始终返回 false。 + public bool IsReadOnly + { + get + { + return false; + } + } + + public ICollection Keys + { + get + { + return HashMapData.Keys; + } + } + + public ICollection Values + { + get + { + return HashMapData.Values; + } + } + + public void Add(KeyValuePair item) + { + if (item.Key == null) + { + throw new ArgumentNullException("key can't be null."); + } + if (HashMapData.ContainsKey(item.Key)) + { + HashMapData[item.Key] = item.Value; + } + else + { + HashMapData.Add(item.Key, item.Value); + } + } + + public void Add(TKey key, TValue value) + { + if (key == null) + { + throw new ArgumentNullException("key can't be null."); + } + if (HashMapData.ContainsKey(key)) + { + HashMapData[key] = value; + } + else + { + HashMapData.Add(key, value); + } + } + + public void Clear() + { + HashMapData.Clear(); + } + + public bool Contains(KeyValuePair item) + { + return HashMapData.Contains(item); + } + + public bool ContainsKey(TKey key) + { + return HashMapData.ContainsKey(key); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + if (array == null) + { + return; + } + if (array.Length <= arrayIndex) + { + return; + } + int count = array.Length; + for (int i = 0; i < count; i++) + { + if (HashMapData.ContainsKey(array[i].Key)) + { + HashMapData[array[i].Key] = array[i].Value; + } + else + { + HashMapData.Add(array[i].Key, array[i].Value); + } + } + } + + public IEnumerator> GetEnumerator() + { + return HashMapData.GetEnumerator(); + } + + public bool Remove(KeyValuePair item) + { + if (HashMapData.ContainsKey(item.Key) && HashMapData.ContainsValue(item.Value)) + { + return HashMapData.Remove(item.Key); + } + return false; + } + + public bool Remove(TKey key) + { + return HashMapData.Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + try + { + if (HashMapData.ContainsKey(key)) + { + value = HashMapData[key]; + return true; + } + else + { + value = default(TValue); + return false; + } + } + catch + { + value = default(TValue); + return false; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return HashMapData.GetEnumerator(); + } +} diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/HashMap.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/HashMap.cs.meta new file mode 100644 index 0000000..957055b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/HashMap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d18bd5b88649b44191b5f1575b4bade +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister.meta b/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister.meta new file mode 100644 index 0000000..bfd8571 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4028683a4adb4d3dbc666e24c37e034a +timeCreated: 1756370870 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister/UnRegisterOnDestroyTrigger.cs b/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister/UnRegisterOnDestroyTrigger.cs new file mode 100644 index 0000000..af0fd0a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister/UnRegisterOnDestroyTrigger.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace Stary.Evo +{ + + /// + /// 用于注销的接口(为了防止注册后忘记注销特实现此接口) + /// + public interface IUnRegister + { + void UnRegister(); + } + public interface IUnRegisterList + { + List UnregisterList { get; } + } + public static class IUnRegisterListExtension + { + public static void AddToUnregisterList(this IUnRegister self, IUnRegisterList unRegisterList) + { + unRegisterList.UnregisterList.Add(self); + } + + public static void UnRegisterAll(this IUnRegisterList self) + { + foreach (var unRegister in self.UnregisterList) + { + unRegister.UnRegister(); + } + + self.UnregisterList.Clear(); + } + } + /// + /// 自定义可注销的类 + /// + public struct CustomUnRegister : IUnRegister + { + /// + /// 委托对象 + /// + private Action mOnUnRegister { get; set; } + + /// + /// 带参构造函数 + /// + /// + public CustomUnRegister(Action onUnRegsiter) + { + mOnUnRegister = onUnRegsiter; + } + + /// + /// 资源释放 + /// + public void UnRegister() + { + mOnUnRegister.Invoke(); + mOnUnRegister = null; + } + } + /// + /// 注销的触发器 + /// + public class UnRegisterOnDestroyTrigger : MonoBehaviour + { + private HashSet mUnRegisters = new HashSet(); + + public void AddUnRegister(IUnRegister unRegister) + { + mUnRegisters.Add(unRegister); + } + public void RemoveUnRegister(IUnRegister unRegister) + { + mUnRegisters.Remove(unRegister); + } + + private void OnDestroy() + { + foreach (var unRegister in mUnRegisters) + { + unRegister.UnRegister(); + } + + mUnRegisters.Clear(); + } + } + + /// + /// 注销触发器的使用简化 + /// + public static class UnRegisterExtension + { + public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister unRegister, GameObject gameObject) + { + var trigger = gameObject.GetComponent()??null; + + if (!trigger) + { + trigger = gameObject.AddComponent(); + } + + trigger.AddUnRegister(unRegister); + + return unRegister; + } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister/UnRegisterOnDestroyTrigger.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister/UnRegisterOnDestroyTrigger.cs.meta new file mode 100644 index 0000000..af7dd48 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/UnRegister/UnRegisterOnDestroyTrigger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 81fe5c4dfa304c2ab19ebf1cc876813e +timeCreated: 1730381395 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest.meta new file mode 100644 index 0000000..ab7b2ea --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6e78a7eef5a34718801ad2765ad7d475 +timeCreated: 1756370914 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/WebRequestSystem.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/WebRequestSystem.cs new file mode 100644 index 0000000..28780d4 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/WebRequestSystem.cs @@ -0,0 +1,400 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using Cysharp.Threading.Tasks; +using Newtonsoft.Json; +using UnityEngine; +using UnityEngine.Networking; + +namespace Stary.Evo +{ + public static class WebRequestSystem + { + private static string authorization; + + public static async Task Login(string url, string username, string password) + { + var data = new + { + username = username, + password = password, + roleType = "client", + }; + string postData = JsonConvert.SerializeObject(data); + try + { +#if UNITY_2021_3_OR_NEWER + using UnityWebRequest webRequest = UnityWebRequest.PostWwwForm(url, postData); +#else + using UnityWebRequest webRequest = UnityWebRequest.PostWwwForm(url, postData); +#endif + + byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(postData); + webRequest.uploadHandler = new UploadHandlerRaw(postBytes); + webRequest.SetRequestHeader("Content-Type", "application/json"); + webRequest.timeout = 10; + await webRequest.SendWebRequest(); + webRequest.uploadHandler?.Dispose(); + // 更新错误检查方式 + if (webRequest.result == UnityWebRequest.Result.ConnectionError || + webRequest.result == UnityWebRequest.Result.ProtocolError) + { + Debug.LogError(webRequest.error); + } + else + { + ResultMessageEntity authResponse = + JsonConvert.DeserializeObject(webRequest.downloadHandler.text); + Debug.Log("UnityEvo:ResultMessageEntity" + authResponse.data); + if (authResponse.code == 200) + { + AuthenticationResponse authResponseData = + JsonConvert.DeserializeObject(authResponse.data.ToString()); + Debug.Log("UnityEvo:AuthenticationResponse" + authResponseData.Token); + authorization = authResponseData.Token; + PlayerPrefs.SetString("Authorization", authorization); + Debug.Log("UnityEvo:登录成功"); + return true; + } + } + + return false; + } + catch (Exception e) + { + Debug.LogError($"UnityEvo:WebRequestSystem.Login" + e.Message); + return false; + } + } + + /// + /// GET请求数据 + /// + /// 请求数据的URL地址 + /// token验证的参数,此处为authorization + /// + public static async Task GetValidateToken(string url) + { + authorization = PlayerPrefs.GetString("Authorization"); + try + { + using UnityWebRequest webRequest = UnityWebRequest.Get($"{url}?token={authorization}"); + webRequest.downloadHandler = new DownloadHandlerBuffer(); + webRequest.timeout = 10; + await webRequest.SendWebRequest(); + // 增强错误处理 + if (webRequest.result != UnityWebRequest.Result.Success) + { + var errorMsg = $"HTTP {webRequest.responseCode}\n" + + $"URL: {url}\n" + + $"Error: {webRequest.error}\n" + + $"Response: {webRequest.downloadHandler.text}"; + + Debug.LogError(errorMsg); + return false; + } + + ResultMessageEntity resultMessageEntity = + JsonConvert.DeserializeObject(webRequest.downloadHandler.text); + if (resultMessageEntity.code == 200) + return true; // 添加返回值 + + + return false; + } + catch (Exception e) + { + Debug.LogError($"UnityEvo:WebRequestSystem.GetValidateToken" + e.Message); + return false; + } + } + + /// + /// POST请求数据 + /// + /// 获取Token值的服务URL地址(很重要) + /// 传入请求的参数,此处参数为JOSN格式 + /// + public static async Task PostFile(string url, string[] path) + { + if (!GetTokenState()) + { + Debug.LogError("用户未登录,请先登录"); + return new ResultMessageEntity() + { + code = 2001, + message = "用户未登录,请先登录" + }; + } + + //UnityWebRequest[] files = new UnityWebRequest[3]; + WWWForm form = new WWWForm(); + + for (int i = 0; i < path.Length; i++) + { + byte[] bytes = await File.ReadAllBytesAsync(path[i]); + form.AddBinaryData("files[]", bytes, Path.GetFileName(path[i])); + } + + try + { + using UnityWebRequest webRequest = UnityWebRequest.Post(url, form); + webRequest.SetRequestHeader("Authorization", authorization); + webRequest.disposeUploadHandlerOnDispose = true; + webRequest.disposeDownloadHandlerOnDispose = true; + webRequest.disposeCertificateHandlerOnDispose = true; + webRequest.timeout = 60; + await webRequest.SendWebRequest(); + webRequest.uploadHandler?.Dispose(); + // 更新错误检查方式 + if (webRequest.result == UnityWebRequest.Result.ConnectionError || + webRequest.result == UnityWebRequest.Result.ProtocolError) + { + Debug.LogError(webRequest.error); + return new ResultMessageEntity() + { + code = 5001, + message = webRequest.error + }; + } + else + { + ResultMessageEntity resultMessageEntity = + JsonConvert.DeserializeObject(webRequest.downloadHandler.text); + if (resultMessageEntity.code != 200) + { + Debug.LogError("上传异常,无文件数据返回!!"); + } + + return resultMessageEntity; + } + } + catch (Exception e) + { + Debug.LogError($"UnityEvo:WebRequestSystem.PostFile" + e.Message); + return new ResultMessageEntity() + { + code = 5001, + message = e.Message + }; + } + } + + /// + /// GET请求数据 + /// + /// 请求数据的URL地址 + /// token验证的参数,此处为authorization + /// + public static async Task GetFile(string url, string tempPath, + Action downloadProgress = null) + { + if (!GetTokenState()) + { + Debug.LogError("用户未登录,请先登录"); + return new ResultMessageEntity() + { + code = 2001, + message = "用户未登录,请先登录" + }; + } + + try + { + using UnityWebRequest webRequest = UnityWebRequest.Get(url); + webRequest.downloadHandler = new DownloadHandlerFile(tempPath); + if (authorization != null) + webRequest.SetRequestHeader("Authorization", authorization); // 修正请求头名称规范 + + + var operation = webRequest.SendWebRequest(); + while (!operation.isDone) + { + downloadProgress?.Invoke(webRequest.downloadProgress); + await UniTask.Yield(); + } + + // 增强错误处理 + if (webRequest.result != UnityWebRequest.Result.Success) + { + var errorMsg = $"HTTP {webRequest.responseCode}\n" + + $"URL: {url}\n" + + $"Error: {webRequest.error}\n"; + + Debug.LogError(errorMsg); + return new ResultMessageEntity() + { + code = 5001, + message = errorMsg + }; + } + else + { + return new ResultMessageEntity() + { + code = 200, + message = "下载成功" + }; + } + } + catch (Exception e) + { + Debug.LogError($"UnityEvo:WebRequestSystem.GetFile" + e.Message); + + return new ResultMessageEntity() + { + code = 5001, + message = e.Message + }; + } + } + + /// + /// POST请求数据 + /// + /// 获取Token值的服务URL地址(很重要) + /// 传入请求的参数,此处参数为JOSN格式 + /// + public static async Task Post(string url, string postData) + { + if (!GetTokenState()) + { + Debug.LogError("用户未登录,请先登录"); + return new ResultMessageEntity() + { + code = 2001, + message = "用户未登录,请先登录" + }; + } + + try + { +#if UNITY_2021_3_OR_NEWER + using (UnityWebRequest webRequest = UnityWebRequest.PostWwwForm(url, postData)) //第二种写法此行注释 +#else + using (UnityWebRequest webRequest = UnityWebRequest.PostWwwForm(url, postData)) //第二种写法此行注释 +#endif + { + byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(postData); + webRequest.uploadHandler = new UploadHandlerRaw(postBytes); + webRequest.SetRequestHeader("Content-Type", "application/json"); + webRequest.SetRequestHeader("Authorization", authorization); + webRequest.disposeUploadHandlerOnDispose = true; + webRequest.disposeDownloadHandlerOnDispose = true; + webRequest.disposeCertificateHandlerOnDispose = true; + webRequest.timeout = 20; + await webRequest.SendWebRequest(); + webRequest.uploadHandler?.Dispose(); + // 更新错误检查方式 + if (webRequest.result == UnityWebRequest.Result.ConnectionError || + webRequest.result == UnityWebRequest.Result.ProtocolError) + { + Debug.LogError(webRequest.error); + return new ResultMessageEntity() + { + code = 5001, + message = webRequest.error + }; + } + else + { + ResultMessageEntity resultMessageEntity = + JsonConvert.DeserializeObject(webRequest.downloadHandler.text); + if (resultMessageEntity.code != 200) + { + Debug.LogError(resultMessageEntity.message); + } + + return resultMessageEntity; + } + } + } + catch (Exception e) + { + Debug.LogError($"UnityEvo:WebRequestSystem.Post" + e.Message); + + return new ResultMessageEntity() + { + code = 5001, + message = e.Message + }; + } + } + + /// + /// GET请求数据 + /// + /// 请求数据的URL地址 + /// token验证的参数,此处为authorization + /// + public static async Task Get(string url) + { + if (!GetTokenState()) + { + Debug.LogError("用户未登录,请先登录"); + return new ResultMessageEntity() + { + code = 2001, + message = "用户未登录,请先登录" + }; + } + + try + { + using UnityWebRequest webRequest = UnityWebRequest.Get(url); + webRequest.downloadHandler = new DownloadHandlerBuffer(); + if (authorization != null) + webRequest.SetRequestHeader("Authorization", authorization); // 修正请求头名称规范 + + webRequest.timeout = 20; + await webRequest.SendWebRequest(); + + // 增强错误处理 + if (webRequest.result != UnityWebRequest.Result.Success) + { + var errorMsg = $"HTTP {webRequest.responseCode}\n" + + $"URL: {url}\n" + + $"Error: {webRequest.error}\n" + + $"Response: {webRequest.downloadHandler.text}"; + + Debug.LogError(errorMsg); + return new ResultMessageEntity() + { + code = 5001, + message = errorMsg + }; + } + + ResultMessageEntity resultMessageEntity = + JsonConvert.DeserializeObject(webRequest.downloadHandler.text); + if (resultMessageEntity.code != 200) + { + Debug.LogError(resultMessageEntity.message); + } + + return resultMessageEntity; + } + catch (Exception e) + { + Debug.LogError($"UnityEvo:WebRequestSystem.Get" + e.Message); + return new ResultMessageEntity() + { + code = 5001, + message = e.Message + }; + } + } + + + public static bool GetTokenState() + { + if (string.IsNullOrEmpty(authorization)) + { + return false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/WebRequestSystem.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/WebRequestSystem.cs.meta new file mode 100644 index 0000000..aa13487 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/WebRequestSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 213225eda91d466eacd34d1b2211aa09 +timeCreated: 1741230908 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity.meta new file mode 100644 index 0000000..635662a --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 12dc863cf4103524684058c5ee5c3e7d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests.meta new file mode 100644 index 0000000..fadd68d --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 01117cad0b5a3e942bdf3063d67c301f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/AuthenticationRequest.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/AuthenticationRequest.cs new file mode 100644 index 0000000..cdd6441 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/AuthenticationRequest.cs @@ -0,0 +1,29 @@ + + + +namespace Stary.Evo +{ + /// + /// 用户详细信息 + /// + public class RegisterRequest + { + public string userName { get; set; } + public string passWord { get; set; } + + public string email { get; set; } + + public string phoneNumber { get; set; } + + public string res { get; set; } + } + + public class LoginRequest + { + public string userName { get; set; } + public string passWord { get; set; } + public string roleType { get; set; } + public string res { get; set; } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/AuthenticationRequest.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/AuthenticationRequest.cs.meta new file mode 100644 index 0000000..56e1446 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/AuthenticationRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 137fc1fb32d62bf4e9220f60e870027c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResDmainRequest.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResDmainRequest.cs new file mode 100644 index 0000000..924e2c0 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResDmainRequest.cs @@ -0,0 +1,22 @@ + + + +namespace Stary.Evo +{ + public struct ResDmainAddRequst + { + public string ProductName { get; set; } + public string DomainName { get; set; } + public string PackageVersion { get; set; } + public string Platform { get; set; } + public string DocumentFileId { get; set; } + } + + public struct ResDmainRequst + { + public string ProductName { get; set; } + public string DomainName { get; set; } + public string Platform { get; set; } + } + +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResDmainRequest.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResDmainRequest.cs.meta new file mode 100644 index 0000000..d6010af --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResDmainRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4371251d7562cbf46869e2ee63b43d51 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResultMessageEntity.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResultMessageEntity.cs new file mode 100644 index 0000000..9aa5350 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResultMessageEntity.cs @@ -0,0 +1,10 @@ + +namespace Stary.Evo +{ + public struct ResultMessageEntity + { + public int code { get; set; } + public string message { get; set; } + public object data { get; set; } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResultMessageEntity.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResultMessageEntity.cs.meta new file mode 100644 index 0000000..21e0878 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/ResultMessageEntity.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b09f078ce65a4054887040ef346b289d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/UserRequest.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/UserRequest.cs new file mode 100644 index 0000000..566c85b --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/UserRequest.cs @@ -0,0 +1,28 @@ + +namespace Stary.Evo +{ + public class UserRequest + { + + } + + public class ScoreRequest + { + + /// + /// 当前的分数 + /// + public int currentScore { get; set; } + + /// + /// 最大的分数 + /// + public int maxScore { get; set; } + + /// + /// 类型 + /// + /// + public string type { get; set; } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/UserRequest.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/UserRequest.cs.meta new file mode 100644 index 0000000..d75d04e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Requests/UserRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a428b0f418ad164eb68c21015511d8b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses.meta new file mode 100644 index 0000000..dd42e38 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 822c2f63795732943875327b52def5bd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/AuthenticationResponse.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/AuthenticationResponse.cs new file mode 100644 index 0000000..0ac5d77 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/AuthenticationResponse.cs @@ -0,0 +1,13 @@ + +namespace Stary.Evo +{ + public class AuthenticationResponse + { + public string Token { get; set; } + } + + public class EncryptResponse + { + public string res { get; set; } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/AuthenticationResponse.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/AuthenticationResponse.cs.meta new file mode 100644 index 0000000..1cd7254 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/AuthenticationResponse.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 707f3409d71c4fc45b8b7065e7c88808 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/ResDmainResponse.cs b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/ResDmainResponse.cs new file mode 100644 index 0000000..6e72e88 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/ResDmainResponse.cs @@ -0,0 +1,22 @@ + + +namespace Stary.Evo +{ + + public struct ResDmainVersionResponse + { + public string ProductName { get; set; } + public string DomainName { get; set; } + public string Platform { get; set; } + public string PackageVersion { get; set; } + } + + public struct ResDmainResponse + { + public string ProductName { get; set; } + public string DomainName { get; set; } + public string Platform { get; set; } + public string PackageVersion { get; set; } + public string DocumentFileId { get; set; } + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/ResDmainResponse.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/ResDmainResponse.cs.meta new file mode 100644 index 0000000..fe345eb --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/WebRequest/_netCoreEntity/Responses/ResDmainResponse.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b5b41fb1367ea6f438e1de9a9baf1be1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/loading.meta b/Assets/00.StaryEvoTools/Runtime/Tool/loading.meta new file mode 100644 index 0000000..4424648 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/loading.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f731b06eebbbde74ea69563a66c3ae6b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/loading/SplashScreen.cs b/Assets/00.StaryEvoTools/Runtime/Tool/loading/SplashScreen.cs new file mode 100644 index 0000000..11f8cb6 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/loading/SplashScreen.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using Cysharp.Threading.Tasks; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; + +public class SplashScreen : MonoBehaviour +{ + private Image image; + + async void Start() + { + image = GetComponentInChildren(); + // 初始完全透明 + image.color = new Color(1, 1, 1, 0); + + // 渐显效果(2秒) + await Fade(0, 1, 0.5f); + + // 保持显示(原2秒等待) + await UniTask.Delay(TimeSpan.FromSeconds(1)); + + // 渐隐效果(1秒) + await Fade(1, 0, 0.5f); + + await SceneManager.LoadSceneAsync(1); + if (transform != null) + Destroy(gameObject); + } + + + private async UniTask Fade(float startAlpha, float endAlpha, float duration) + { + float elapsed = 0f; + while (elapsed < duration) + { + float alpha = Mathf.Lerp(startAlpha, endAlpha, elapsed / duration); + image.color = new Color(1, 1, 1, alpha); + elapsed += Time.deltaTime; + await UniTask.Yield(); + } + + image.color = new Color(1, 1, 1, endAlpha); + } +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/Tool/loading/SplashScreen.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tool/loading/SplashScreen.cs.meta new file mode 100644 index 0000000..9a4b7e3 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/Tool/loading/SplashScreen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eaccb6795ccb65c479e97450d3227af6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/00.StaryEvoTools/Runtime/com.stary.evotools.runtime.asmdef b/Assets/00.StaryEvoTools/Runtime/com.stary.evotools.runtime.asmdef new file mode 100644 index 0000000..6f1d83e --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/com.stary.evotools.runtime.asmdef @@ -0,0 +1,16 @@ +{ + "name": "com.stary.evotools.runtime", + "rootNamespace": "", + "references": [ + "GUID:f51ebe6a0ceec4240a699833d6309b23" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": true, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/Runtime/com.stary.evotools.runtime.asmdef.meta b/Assets/00.StaryEvoTools/Runtime/com.stary.evotools.runtime.asmdef.meta new file mode 100644 index 0000000..1145027 --- /dev/null +++ b/Assets/00.StaryEvoTools/Runtime/com.stary.evotools.runtime.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f3fa071c399c4383a9ff8115e53dfefc +timeCreated: 1756370719 \ No newline at end of file diff --git a/Assets/00.StaryEvoTools/package.json b/Assets/00.StaryEvoTools/package.json new file mode 100644 index 0000000..154d86f --- /dev/null +++ b/Assets/00.StaryEvoTools/package.json @@ -0,0 +1,34 @@ +{ + "name": "com.staryevo.main", + "version": "1.3.33", + "displayName": "00.StaryEvo", + "description": "This is an Framework package(后台服务器版本,端口9527)", + "unity": "2021.3", + "unityRelease": "30f1", + "author": { + "name": "staryEvo", + "email": "zaze97@163.com", + "url": "" + }, + "repository": { + "type": "git", + "url": "http://192.168.31.100:8088/framework/xosmopluginlibrary.git#02.InformationSave" + }, + "dependencies": { + "com.cysharp.unitask": "2.5.10", + "com.tuyoogame.yooasset": "2.3.7", + "com.staryevo.informationsave": "1.x.x" + }, + "samples": [ + { + "displayName": "Framework Example Scenes", + "description": "", + "path": "Samples~/Test" + }, + { + "displayName": "Loading", + "description": "", + "path": "Samples~/SplashScreen" + } + ] +} diff --git a/Assets/00.StaryEvoTools/package.json.meta b/Assets/00.StaryEvoTools/package.json.meta new file mode 100644 index 0000000..dd5f49b --- /dev/null +++ b/Assets/00.StaryEvoTools/package.json.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: aa6aa0e73dfc4504bde1ba69beaedf85 +timeCreated: 1756370325 \ No newline at end of file