コード例 #1
0
 internal static void OnExcuteUpdate(this MBehaviour behaviour)
 {
     if (!behaviour.IsEnable)
     {
         return;
     }
     behaviour.onUpdate.SendListener();
 }
コード例 #2
0
        /// <summary>
        /// 移除行为
        /// </summary>
        /// <param name="behaviour"></param>
        public static void RemoveBehaviour(MBehaviour behaviour)
        {
            if (!IsContainsBehaviour(behaviour))
            {
                return;
            }

            Behaviours.Remove(behaviour);
        }
コード例 #3
0
        internal static void OnExcuteDisable(this MBehaviour behaviour)
        {
            if (!behaviour.IsEnable)
            {
                return;
            }

            behaviour.onDisable.SendListener();
            behaviour.IsEnable = false;
        }
コード例 #4
0
        internal static void OnExcuteEnable(this MBehaviour behaviour)
        {
            if (!behaviour.IsActive)
            {
                return;
            }

            behaviour.onEnable.SendListener();
            //behaviour.SetEnable();
            behaviour.IsEnable = true;
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        /// <summary>
        /// 添加行为
        /// </summary>
        /// <param name="behaviour"></param>
        public static void AddBehaviour(MBehaviour behaviour)
        {
            if (IsContainsBehaviour(behaviour))
            {
                return;
            }

            Behaviours.Add(behaviour);

            SortBehaviour();
        }
コード例 #7
0
        private static void OnExcuteDisableDestroy(MBehaviour behaviour)
        {
            if (behaviour == null)
            {
                return;
            }

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

            if (!behaviour.IsEnable)
            {
                return;
            }

            behaviour.onStart.SendListener();

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

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

            behaviour.onAwake.SendListener();

            behaviour.IsAwake = true;
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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();
            //    });
            //}
        }
コード例 #13
0
 /// <summary>
 /// 是否存在此行为
 /// </summary>
 /// <param name="behaviour"></param>
 /// <returns></returns>
 internal static bool IsContainsBehaviour(MBehaviour behaviour)
 {
     return(Behaviours.Contains(behaviour));
 }
コード例 #14
0
 public static void OnStart(this MBehaviour behaviour, Action action)
 {
     behaviour.onStart.AddListener(action);
 }
コード例 #15
0
 internal static void OnAwake_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onAwake.AddListener(action);
 }
コード例 #16
0
 public static void OnDestroy(this MBehaviour behaviour, Action action)
 {
     behaviour.onDestroy.AddListener(action);
     MBehaviourController.RemoveBehaviour(behaviour);
 }
コード例 #17
0
 public static void OnDisable(this MBehaviour behaviour, Action action)
 {
     behaviour.onDisable.AddListener(action);
 }
コード例 #18
0
 public static void OnUpdate_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onUpdate.AddListener(action);
 }
コード例 #19
0
 internal static void OnDestroy_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onDestroy.AddListener(action);
 }
コード例 #20
0
 internal static void OnDisable_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onDisable.AddListener(action);
 }
コード例 #21
0
 internal static void OnStart_MBehaviour(this MBehaviour behaviour, Action action)
 {
     behaviour.onStart.AddListener(action);
 }
コード例 #22
0
 public static void OnAwake(this MBehaviour behaviour, Action action)
 {
     behaviour.onAwake.AddListener(action);
 }