Skip to content

Commit

Permalink
delete useless
Browse files Browse the repository at this point in the history
  • Loading branch information
IQzhan committed Mar 14, 2022
1 parent 9fe059f commit 6def70c
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 308 deletions.
8 changes: 0 additions & 8 deletions Editor.meta

This file was deleted.

17 changes: 0 additions & 17 deletions Editor/E.Global.Editor.asmdef

This file was deleted.

7 changes: 0 additions & 7 deletions Editor/E.Global.Editor.asmdef.meta

This file was deleted.

47 changes: 0 additions & 47 deletions Editor/ScriptableObjectAssetsCreator.cs

This file was deleted.

11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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".
Global system time information.
135 changes: 37 additions & 98 deletions Runtime/GlobalBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,6 @@
/// </summary>
public abstract partial class GlobalBehaviour
{
/// <summary>
/// Life state of GlobalBehaviour
/// </summary>
public enum State
{
/// <summary>
/// None -> Awaked
/// </summary>
None = 0,

/// <summary>
/// Invoking OnAwake
/// </summary>
OnAwake = 1,

/// <summary>
/// Awaked -> Enabled or Destroyed
/// </summary>
Awaked = 2,

/// <summary>
/// Invoking OnEnable
/// </summary>
OnEnable = 3,

/// <summary>
/// Enabled -> Updated or Disabled or (Disabled and Destroyed)
/// </summary>
Enabled = 4,

/// <summary>
/// Invoking OnUpdate
/// </summary>
OnUpdate = 5,

/// <summary>
/// Updated -> Disabled or (Disabled and Destroyed)
/// </summary>
Updated = 6,

/// <summary>
/// Invoking OnDisable
/// </summary>
OnDisable = 7,

/// <summary>
/// Disabled -> Enabled or Destroyed
/// </summary>
Disabled = 8,

/// <summary>
/// Invoking OnDestroy
/// </summary>
OnDestroy = -1,

/// <summary>
/// Destroyed
/// </summary>
Destroyed = -2
}

/// <summary>
/// Only runtime id, do not save it.
/// </summary>
Expand All @@ -81,7 +20,7 @@ public enum State
/// <summary>
/// Life state of GlobalBehaviour
/// </summary>
public State LifeState => m_State;
public GlobalBehaviourState LifeState => m_State;

/// <summary>
/// See <see cref="TypeInfo.isExecuteInEditorMode"/>
Expand All @@ -94,7 +33,7 @@ public enum State

internal bool isExecuteInEditorMode = false;

private State m_State = State.None;
private GlobalBehaviourState m_State = GlobalBehaviourState.None;

/// <summary>
/// Control enable state.
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 6def70c

Please sign in to comment.