Exemple #1
0
 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);
        }
Exemple #3
0
        internal static void OnExcuteDisable(this MBehaviour behaviour)
        {
            if (!behaviour.IsEnable)
            {
                return;
            }

            behaviour.onDisable.SendListener();
            behaviour.IsEnable = false;
        }
Exemple #4
0
        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();
        }
Exemple #7
0
        private static void OnExcuteDisableDestroy(MBehaviour behaviour)
        {
            if (behaviour == null)
            {
                return;
            }

            if (!behaviour.IsEnable)
            {
                return;
            }
            behaviour.onDisable.SendListener();
        }
Exemple #8
0
        internal static void OnExcuteStart(this MBehaviour behaviour)
        {
            if (behaviour.IsStart)
            {
                return;
            }

            if (!behaviour.IsEnable)
            {
                return;
            }

            behaviour.onStart.SendListener();

            behaviour.IsStart = true;
        }
Exemple #9
0
        internal static void OnExcuteAwake(this MBehaviour behaviour)
        {
            if (behaviour.IsAwake)
            {
                return;
            }

            //如果没有激活,则跳过
            if (!behaviour.IsActive)
            {
                return;
            }

            behaviour.onAwake.SendListener();

            behaviour.IsAwake = true;
        }
Exemple #10
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 #11
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);
        }
Exemple #12
0
        /// <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);
 }
Exemple #15
0
 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);
 }
Exemple #18
0
 public static void OnUpdate_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onUpdate.AddListener(action);
 }
Exemple #19
0
 internal static void OnDestroy_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onDestroy.AddListener(action);
 }
Exemple #20
0
 internal static void OnDisable_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onDisable.AddListener(action);
 }
Exemple #21
0
 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);
 }