Exemple #1
0
        public MBehaviour(ExecutionPriority priority = ExecutionPriority.Mid, float executionOrder = 0, bool isActive = true)
        {
            this.priority       = priority;
            this.executionOrder = executionOrder;

            this.IsActive = isActive;
            this.isEnable = isActive;

            MBehaviourController.AddBehaviour(this);
        }
Exemple #2
0
        public static void OnExcuteDestroy(this MBehaviour behaviour)
        {
            OnExcuteDisableDestroy(behaviour);

            if (behaviour == null)
            {
                return;
            }

            behaviour.onDestroy.SendListener();

            behaviour.onAwake.RemoveListenerAll();
            behaviour.onEnable.RemoveListenerAll();
            behaviour.onDisable.RemoveListenerAll();
            behaviour.onStart.RemoveListenerAll();
            behaviour.onUpdate.RemoveListenerAll();

            MBehaviourController.RemoveBehaviour(behaviour);
        }
Exemple #3
0
        private void Awake()
        {
            behaviour = new MBehaviour(ExecutionPriority.Highest, -1000, enabled);

            behaviour.OnAwake(() =>
            {
                MUtility.CurrentPlatform = CurrentPlatform;

                SwitchPlatform(Application.platform);
            });

            behaviour.OnDestroy(() =>
            {
                DestoryPlatform(Application.platform);
            });

            DontDestroyOnLoad(gameObject);

            MBehaviourController.AddBehaviour(behaviour);
        }
 public static void OnDestroy(this MBehaviour behaviour, Action action)
 {
     behaviour.onDestroy.AddListener(action);
     MBehaviourController.RemoveBehaviour(behaviour);
 }