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); }
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); }
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); }