public static void AddItem(OverridableMonoBehaviour behaviour) { if (behaviour == null) { throw new NullReferenceException("The behaviour you've tried to add is null!"); } if (isShuttingDown) { return; } AddItemToArray(behaviour); }
public static void RemoveSpecificItem(OverridableMonoBehaviour behaviour) { if (behaviour == null) { throw new NullReferenceException("The behaviour you've tried to remove is null!"); } if (isShuttingDown) { return; } if (Instance != null) { RemoveSpecificItemFromArray(behaviour); } }
private static void AddItemToArray(OverridableMonoBehaviour behaviour) { Type behaviourType = behaviour.GetType(); if (behaviourType.GetMethod("UpdateMe").DeclaringType != overridableMonoBehaviourType) { SubscribeToUpdate(behaviour.UpdateMe); } if (behaviourType.GetMethod("FixedUpdateMe").DeclaringType != overridableMonoBehaviourType) { SubscribeToFixedUpdate(behaviour.FixedUpdateMe); } if (behaviourType.GetMethod("LateUpdateMe").DeclaringType != overridableMonoBehaviourType) { SubscribeToLateUpdate(behaviour.LateUpdateMe); } }
private static void RemoveSpecificItemFromArray(OverridableMonoBehaviour behaviour) { UnsubscribeFromUpdate(behaviour.UpdateMe); UnsubscribeFromFixedUpdate(behaviour.FixedUpdateMe); UnsubscribeFromLateUpdate(behaviour.LateUpdateMe); }