diff --git a/Editor.meta b/Editor.meta deleted file mode 100644 index 385895b..0000000 --- a/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 28d9fe428bf2baf46bf6536bb02e5677 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/E.Global.Editor.asmdef b/Editor/E.Global.Editor.asmdef deleted file mode 100644 index 8d493cf..0000000 --- a/Editor/E.Global.Editor.asmdef +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "E.Global.Editor", - "rootNamespace": "E.Editor", - "references": [ - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Editor/E.Global.Editor.asmdef.meta b/Editor/E.Global.Editor.asmdef.meta deleted file mode 100644 index dc5a794..0000000 --- a/Editor/E.Global.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 0122e4e10964ca846a701ed52d778dd4 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/ScriptableObjectAssetsCreator.cs b/Editor/ScriptableObjectAssetsCreator.cs deleted file mode 100644 index 9828ada..0000000 --- a/Editor/ScriptableObjectAssetsCreator.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.IO; -using UnityEditor; -using UnityEngine; - -namespace E.Editor -{ - public static class ScriptableObjectAssetsCreator - { - [MenuItem("Assets/Create/ScriptableObject To Asset")] - public static void CreateScriptableObjectAsset() - { - UnityEngine.Object obj = Selection.activeObject; - if (obj is MonoScript) - { - MonoScript script = obj as MonoScript; - Type cl = script.GetClass(); - if (cl != null && cl.IsSubclassOf(typeof(ScriptableObject))) - { - string path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]); - CreateScriptableObjectAsset(cl, $"{Path.GetDirectoryName(path)}/{script.name}.asset"); - return; - } - } - Debug.LogWarning("Please select a ScriptableObject script to create asset"); - } - - public static void CreateScriptableObjectAsset(string path) where T : ScriptableObject - { - ScriptableObject scriptObj = ScriptableObject.CreateInstance(); - CreateObjectAsset(scriptObj, path); - } - - public static void CreateScriptableObjectAsset(Type type, string path) - { - ScriptableObject scriptObj = ScriptableObject.CreateInstance(type); - CreateObjectAsset(scriptObj, path); - } - - public static void CreateObjectAsset(UnityEngine.Object obj, string path) - { - AssetDatabase.CreateAsset(obj, path); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - } -} \ No newline at end of file diff --git a/README.md b/README.md index 002f60d..0eb1b7d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,7 @@ -# Global System - +# Global behaviour module ## class GlobalBehavioour & BehaviourManager ### Descript Simulate monobehaviour's methods like 'Awake/OnEnable/Update/OnDisable/OnDestroy'. ## class GlobalTime ### Descript -Global system time information. - -## class ScriptableObjectAssetsCreator -### Descript -Create ScriptableObject asset. -### Usage -Right click ScriptableObject script file and click menu "Create -> ScriptableObject To Asset". \ No newline at end of file +Global system time information. \ No newline at end of file diff --git a/Runtime/GlobalBehaviour.cs b/Runtime/GlobalBehaviour.cs index 09568d1..c452504 100644 --- a/Runtime/GlobalBehaviour.cs +++ b/Runtime/GlobalBehaviour.cs @@ -12,67 +12,6 @@ /// public abstract partial class GlobalBehaviour { - /// - /// Life state of GlobalBehaviour - /// - public enum State - { - /// - /// None -> Awaked - /// - None = 0, - - /// - /// Invoking OnAwake - /// - OnAwake = 1, - - /// - /// Awaked -> Enabled or Destroyed - /// - Awaked = 2, - - /// - /// Invoking OnEnable - /// - OnEnable = 3, - - /// - /// Enabled -> Updated or Disabled or (Disabled and Destroyed) - /// - Enabled = 4, - - /// - /// Invoking OnUpdate - /// - OnUpdate = 5, - - /// - /// Updated -> Disabled or (Disabled and Destroyed) - /// - Updated = 6, - - /// - /// Invoking OnDisable - /// - OnDisable = 7, - - /// - /// Disabled -> Enabled or Destroyed - /// - Disabled = 8, - - /// - /// Invoking OnDestroy - /// - OnDestroy = -1, - - /// - /// Destroyed - /// - Destroyed = -2 - } - /// /// Only runtime id, do not save it. /// @@ -81,7 +20,7 @@ public enum State /// /// Life state of GlobalBehaviour /// - public State LifeState => m_State; + public GlobalBehaviourState LifeState => m_State; /// /// See @@ -94,7 +33,7 @@ public enum State internal bool isExecuteInEditorMode = false; - private State m_State = State.None; + private GlobalBehaviourState m_State = GlobalBehaviourState.None; /// /// Control enable state. @@ -129,19 +68,19 @@ protected virtual void OnDestroy() { } internal bool InternalAwake() { if (!(Utility.IsPlaying || IsExecuteInEditorMode)) return false; - if (m_State == State.None) + if (m_State == GlobalBehaviourState.None) { - m_State = State.OnAwake; + m_State = GlobalBehaviourState.OnAwake; try { OnAwake(); - if (m_State == State.OnAwake) - m_State = State.Awaked; + if (m_State == GlobalBehaviourState.OnAwake) + m_State = GlobalBehaviourState.Awaked; return true; } catch (System.Exception e) { - m_State = State.None; + m_State = GlobalBehaviourState.None; if (Utility.AllowLogError) { Utility.LogException(e); @@ -155,17 +94,17 @@ internal bool InternalEnable() { switch (m_State) { - case State.Awaked: - case State.Disabled: - State temp = m_State; + case GlobalBehaviourState.Awaked: + case GlobalBehaviourState.Disabled: + GlobalBehaviourState temp = m_State; try { if (IsActive) { - m_State = State.OnEnable; + m_State = GlobalBehaviourState.OnEnable; OnEnable(); - if (m_State == State.OnEnable) - m_State = State.Enabled; + if (m_State == GlobalBehaviourState.OnEnable) + m_State = GlobalBehaviourState.Enabled; return true; } } @@ -186,17 +125,17 @@ internal bool InternalUpdate() { switch (m_State) { - case State.Enabled: - case State.Updated: - State temp = m_State; + case GlobalBehaviourState.Enabled: + case GlobalBehaviourState.Updated: + GlobalBehaviourState temp = m_State; try { if (IsActive) { - m_State = State.OnUpdate; + m_State = GlobalBehaviourState.OnUpdate; OnUpdate(); - if (m_State == State.OnUpdate) - m_State = State.Updated; + if (m_State == GlobalBehaviourState.OnUpdate) + m_State = GlobalBehaviourState.Updated; return true; } } @@ -217,17 +156,17 @@ internal bool InternalDisable() { switch (m_State) { - case State.Enabled: - case State.Updated: - State temp = m_State; + case GlobalBehaviourState.Enabled: + case GlobalBehaviourState.Updated: + GlobalBehaviourState temp = m_State; try { if (!IsActive) { - m_State = State.OnDisable; + m_State = GlobalBehaviourState.OnDisable; OnDisable(); - if (m_State == State.OnDisable) - m_State = State.Disabled; + if (m_State == GlobalBehaviourState.OnDisable) + m_State = GlobalBehaviourState.Disabled; return true; } } @@ -246,13 +185,13 @@ internal bool InternalDisable() internal bool InternalDestroy() { - if (m_State < State.OnAwake) return false; - State temp = m_State; - if (m_State < State.OnDisable) + if (m_State < GlobalBehaviourState.OnAwake) return false; + GlobalBehaviourState temp = m_State; + if (m_State < GlobalBehaviourState.OnDisable) { try { - m_State = State.OnDisable; + m_State = GlobalBehaviourState.OnDisable; OnDisable(); } catch (System.Exception e) @@ -267,9 +206,9 @@ internal bool InternalDestroy() } try { - m_State = State.OnDestroy; + m_State = GlobalBehaviourState.OnDestroy; OnDestroy(); - m_State = State.Destroyed; + m_State = GlobalBehaviourState.Destroyed; return true; } catch (System.Exception e) @@ -287,8 +226,8 @@ internal bool CheckEnable() { switch (m_State) { - case State.Awaked: - case State.Disabled: + case GlobalBehaviourState.Awaked: + case GlobalBehaviourState.Disabled: return IsActive; } return false; @@ -298,8 +237,8 @@ internal bool CheckUpdate() { switch (m_State) { - case State.Enabled: - case State.Updated: + case GlobalBehaviourState.Enabled: + case GlobalBehaviourState.Updated: return IsActive; } return false; @@ -309,8 +248,8 @@ internal bool CheckDisable() { switch (m_State) { - case State.Enabled: - case State.Updated: + case GlobalBehaviourState.Enabled: + case GlobalBehaviourState.Updated: return !IsActive; } return false; diff --git a/Runtime/GlobalBehaviourState.cs b/Runtime/GlobalBehaviourState.cs new file mode 100644 index 0000000..dc74c32 --- /dev/null +++ b/Runtime/GlobalBehaviourState.cs @@ -0,0 +1,66 @@ +namespace E +{ + public abstract partial class GlobalBehaviour + { + /// + /// Life state of GlobalBehaviour + /// + public enum GlobalBehaviourState + { + /// + /// None -> Awaked + /// + None = 0, + + /// + /// Invoking OnAwake + /// + OnAwake = 1, + + /// + /// Awaked -> Enabled or Destroyed + /// + Awaked = 2, + + /// + /// Invoking OnEnable + /// + OnEnable = 3, + + /// + /// Enabled -> Updated or Disabled or (Disabled and Destroyed) + /// + Enabled = 4, + + /// + /// Invoking OnUpdate + /// + OnUpdate = 5, + + /// + /// Updated -> Disabled or (Disabled and Destroyed) + /// + Updated = 6, + + /// + /// Invoking OnDisable + /// + OnDisable = 7, + + /// + /// Disabled -> Enabled or Destroyed + /// + Disabled = 8, + + /// + /// Invoking OnDestroy + /// + OnDestroy = -1, + + /// + /// Destroyed + /// + Destroyed = -2 + } + } +} \ No newline at end of file diff --git a/Editor/ScriptableObjectAssetsCreator.cs.meta b/Runtime/GlobalBehaviourState.cs.meta similarity index 83% rename from Editor/ScriptableObjectAssetsCreator.cs.meta rename to Runtime/GlobalBehaviourState.cs.meta index d624ee9..368ba40 100644 --- a/Editor/ScriptableObjectAssetsCreator.cs.meta +++ b/Runtime/GlobalBehaviourState.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4974adfae76372445bbdef128eb00f54 +guid: c1a1f77ccca07b44d9b0fbfb100b7ac0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/ICallback.cs b/Runtime/ICallback.cs deleted file mode 100644 index 2664f53..0000000 --- a/Runtime/ICallback.cs +++ /dev/null @@ -1,106 +0,0 @@ -namespace E -{ - public interface ICallback { } - - public interface IAction : ICallback - { public void Invoke(); } - - public interface IAction : ICallback - { public void Invoke(T0 t0); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14); } - - public interface IAction : ICallback - { public void Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15); } - - public interface IFunction : ICallback - { public TResult Invoke(); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14); } - - public interface IFunction : ICallback - { public TResult Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15); } -} \ No newline at end of file diff --git a/Runtime/ICallback.cs.meta b/Runtime/ICallback.cs.meta deleted file mode 100644 index 3591be0..0000000 --- a/Runtime/ICallback.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2edaeee5bcf524e4f94914b4896f2e0f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Utility.cs b/Runtime/Utility.cs index 619ed56..769e853 100644 --- a/Runtime/Utility.cs +++ b/Runtime/Utility.cs @@ -26,8 +26,10 @@ public static void CreateAssetIfNotExists() where T : ScriptableObject { AssetDatabase.CreateFolder($"{assetsFolderStr}/{settingsFolderStr}", resourcesStr); } - Editor.ScriptableObjectAssetsCreator. - CreateScriptableObjectAsset($"{assetsFolderStr}/{settingsFolderStr}/{resourcesStr}/{typeof(T).Name}.asset"); + ScriptableObject scriptObj = ScriptableObject.CreateInstance(); + AssetDatabase.CreateAsset(scriptObj, $"{assetsFolderStr}/{settingsFolderStr}/{resourcesStr}/{typeof(T).Name}.asset"); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); } } #endif diff --git a/package.json b/package.json index ff28bf3..ed733b6 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "com.e.global", "displayName": "Global", - "description": "Simulate monobehaviour's methods like 'Awake/OnEnable/Update/OnDisable/OnDestroy',and some other tools.", - "version": "1.1.0", + "description": "Simulate monobehaviour's methods like 'Awake/OnEnable/Update/OnDisable/OnDestroy'.", + "version": "1.1.1", "unity": "2019.3", "license": "MIT", "keywords": [