Skip to content

Commit

Permalink
fixed #485
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonXuDeveloper committed Jun 26, 2023
1 parent 2668a73 commit 76a3f2d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ public void Awake()
//就mono订阅start和update事件
LifeCycleMgr.Instance.AddStartItem(instance, GetMethodInfo(type, "Start"));
LifeCycleMgr.Instance.AddFixedUpdateItem(instance, GetMethodInfo(type, "FixedUpdate"),
gameObject);
LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject);
gameObject, ()=> enabled);
LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject,
() => enabled);
LifeCycleMgr.Instance.AddLateUpdateItem(instance, GetMethodInfo(type, "LateUpdate"),
gameObject);
gameObject, () => enabled);

isAwaking = false;
awaked = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static void Initialize()
/// <summary>
/// 最大数量
/// </summary>
private const int MaxSize = 10000;
private const int MaxSize = 30000;

/// <summary>
/// 锁
Expand Down Expand Up @@ -286,12 +286,13 @@ public void AddUpdateItem(object instance, MethodInfo method)
/// <param name="instance"></param>
/// <param name="method"></param>
/// <param name="parent"></param>
public void AddUpdateItem<T>(T instance, MethodInfo method, GameObject parent) where T : class
/// <param name="cond"></param>
public void AddUpdateItem<T>(T instance, MethodInfo method, GameObject parent, Func<bool> cond = null) where T : class
{
void* ptr = UnsafeUtility.PinGCObjectAndGetAddress(instance, out var address);
_updateItems.Add(GetLifeCycleItem(in ptr, in address,
() => method?.Invoke(instance, ConstMgr.NullObjects),
() => parent.activeInHierarchy));
() => cond == null ? parent.activeInHierarchy : parent.activeInHierarchy && cond.Invoke()));
}

/// <summary>
Expand Down Expand Up @@ -360,11 +361,13 @@ public void AddLateUpdateItem(object instance, MethodInfo method)
/// <param name="instance"></param>
/// <param name="method"></param>
/// <param name="parent"></param>
public void AddLateUpdateItem<T>(T instance, MethodInfo method, GameObject parent) where T : class
/// <param name="cond"></param>
public void AddLateUpdateItem<T>(T instance, MethodInfo method, GameObject parent, Func<bool> cond = null) where T : class
{
void* ptr = UnsafeUtility.PinGCObjectAndGetAddress(instance, out var address);
_lateUpdateItems.Add(GetLifeCycleItem(in ptr, in address,
() => method?.Invoke(instance, ConstMgr.NullObjects), () => parent.activeInHierarchy));
() => method?.Invoke(instance, ConstMgr.NullObjects),
() => cond == null ? parent.activeInHierarchy : parent.activeInHierarchy && cond.Invoke()));
}

/// <summary>
Expand Down Expand Up @@ -404,11 +407,13 @@ public void AddFixedUpdateItem(object instance, MethodInfo method)
/// <param name="instance"></param>
/// <param name="method"></param>
/// <param name="parent"></param>
public void AddFixedUpdateItem<T>(T instance, MethodInfo method, GameObject parent) where T : class
/// <param name="cond"></param>
public void AddFixedUpdateItem<T>(T instance, MethodInfo method, GameObject parent, Func<bool> cond = null) where T : class
{
void* ptr = UnsafeUtility.PinGCObjectAndGetAddress(instance, out var address);
_fixedUpdateItems.Add(GetLifeCycleItem(in ptr, in address,
() => method?.Invoke(instance, ConstMgr.NullObjects), () => parent.activeInHierarchy));
() => method?.Invoke(instance, ConstMgr.NullObjects),
() => cond == null ? parent.activeInHierarchy : parent.activeInHierarchy && cond.Invoke()));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
//就mono订阅start和update事件
LifeCycleMgr.Instance.AddStartItem(instance, GetMethodInfo(type, "Start"));
LifeCycleMgr.Instance.AddFixedUpdateItem(instance, GetMethodInfo(type, "FixedUpdate"),
gameObject);
LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject);
gameObject, ()=> enabled);
LifeCycleMgr.Instance.AddUpdateItem(instance, GetMethodInfo(type, "Update"), gameObject,
() => enabled);
LifeCycleMgr.Instance.AddLateUpdateItem(instance, GetMethodInfo(type, "LateUpdate"),
gameObject);
gameObject, () => enabled);

isAwaking = false;
awaked = true;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 76a3f2d

Please sign in to comment.