Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 private static void RemoveSpecificItemFromArray(OverridableMonoBehaviour behaviour)
 {
     UnsubscribeFromUpdate(behaviour.UpdateMe);
     UnsubscribeFromFixedUpdate(behaviour.FixedUpdateMe);
     UnsubscribeFromLateUpdate(behaviour.LateUpdateMe);
 }