internal static void OnExcuteUpdate(this MBehaviour behaviour) { if (!behaviour.IsEnable) { return; } behaviour.onUpdate.SendListener(); }
/// <summary> /// 移除行为 /// </summary> /// <param name="behaviour"></param> public static void RemoveBehaviour(MBehaviour behaviour) { if (!IsContainsBehaviour(behaviour)) { return; } Behaviours.Remove(behaviour); }
internal static void OnExcuteDisable(this MBehaviour behaviour) { if (!behaviour.IsEnable) { return; } behaviour.onDisable.SendListener(); behaviour.IsEnable = false; }
internal static void OnExcuteEnable(this MBehaviour behaviour) { if (!behaviour.IsActive) { return; } behaviour.onEnable.SendListener(); //behaviour.SetEnable(); behaviour.IsEnable = true; }
public static void OnExcuteDestroy(this MBehaviour behaviour) { OnExcuteDisable(behaviour); behaviour.onDestroy.SendListener(); behaviour.onAwake.RemoveListenerAll(); behaviour.onEnable.RemoveListenerAll(); behaviour.onDisable.RemoveListenerAll(); behaviour.onStart.RemoveListenerAll(); behaviour.onUpdate.RemoveListenerAll(); }
/// <summary> /// 添加行为 /// </summary> /// <param name="behaviour"></param> public static void AddBehaviour(MBehaviour behaviour) { if (IsContainsBehaviour(behaviour)) { return; } Behaviours.Add(behaviour); SortBehaviour(); }
private static void OnExcuteDisableDestroy(MBehaviour behaviour) { if (behaviour == null) { return; } if (!behaviour.IsEnable) { return; } behaviour.onDisable.SendListener(); }
internal static void OnExcuteStart(this MBehaviour behaviour) { if (behaviour.IsStart) { return; } if (!behaviour.IsEnable) { return; } behaviour.onStart.SendListener(); behaviour.IsStart = true; }
internal static void OnExcuteAwake(this MBehaviour behaviour) { if (behaviour.IsAwake) { return; } //如果没有激活,则跳过 if (!behaviour.IsActive) { return; } behaviour.onAwake.SendListener(); behaviour.IsAwake = true; }
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); }
/// <summary> /// 添加行为 /// </summary> /// <param name="behaviour"></param> internal static void AddBehaviour(MBehaviour behaviour) { if (IsContainsBehaviour(behaviour)) { return; } Behaviours.Add(behaviour); SortBehaviour(); //if(IsInitialize) //{ // Instance.ExcuteDelay(() => // { // behaviour.OnExcuteAwake(); // behaviour.OnExcuteEnable(); // behaviour.OnExcuteStart(); // }); //} }
/// <summary> /// 是否存在此行为 /// </summary> /// <param name="behaviour"></param> /// <returns></returns> internal static bool IsContainsBehaviour(MBehaviour behaviour) { return(Behaviours.Contains(behaviour)); }
public static void OnStart(this MBehaviour behaviour, Action action) { behaviour.onStart.AddListener(action); }
internal static void OnAwake_MBehaviour(this MBehaviour behaviour, Action action) { behaviour.onAwake.AddListener(action); }
public static void OnDestroy(this MBehaviour behaviour, Action action) { behaviour.onDestroy.AddListener(action); MBehaviourController.RemoveBehaviour(behaviour); }
public static void OnDisable(this MBehaviour behaviour, Action action) { behaviour.onDisable.AddListener(action); }
public static void OnUpdate_MBehaviour(this MBehaviour behaviour, Action action) { behaviour.onUpdate.AddListener(action); }
internal static void OnDestroy_MBehaviour(this MBehaviour behaviour, Action action) { behaviour.onDestroy.AddListener(action); }
internal static void OnDisable_MBehaviour(this MBehaviour behaviour, Action action) { behaviour.onDisable.AddListener(action); }
internal static void OnStart_MBehaviour(this MBehaviour behaviour, Action action) { behaviour.onStart.AddListener(action); }
public static void OnAwake(this MBehaviour behaviour, Action action) { behaviour.onAwake.AddListener(action); }