Пример #1
0
    public void Add <T> (T _instance_)
    {
        IUpdate update = _instance_ as IUpdate;

        if (update != null)
        {
            AddUpdate(update);
        }

        IFixedUpdate fixedUpdate = _instance_ as IFixedUpdate;

        if (fixedUpdate != null)
        {
            AddFixedUpdate(fixedUpdate);
        }

        ILateUpdate lateUpdate = _instance_ as ILateUpdate;

        if (lateUpdate != null)
        {
            AddLateUpdate(lateUpdate);
        }

#if UNITY_EDITOR
        UpdateRuntimeTimerCount();
#endif
    }
Пример #2
0
    public void Remove <T> (T _inst)
    {
        IUpdate update = _inst as IUpdate;

        if (update != null)
        {
            RemoveUpdate(update);
        }

        IFixedUpdate fixedUpdate = _inst as IFixedUpdate;

        if (fixedUpdate != null)
        {
            RemoveFixedUpdate(fixedUpdate);
        }

        ILateUpdate lateUpdate = _inst as ILateUpdate;

        if (lateUpdate != null)
        {
            RemoveLateUpdate(lateUpdate);
        }

#if UNITY_EDITOR
        UpdateRuntimeTimerCount();
#endif
    }
Пример #3
0
    /// <summary>
    /// 是否存在此实例
    /// </summary>
    /// <param name="_instance_"></param>
    /// <returns></returns>
    public bool Exist <T> (T _instance_)
    {
        IUpdate update = _instance_ as IUpdate;

        if (update != null)
        {
            return(_UpdateStore.Contains(update));
        }

        IFixedUpdate fixedUpdate = _instance_ as IFixedUpdate;

        if (fixedUpdate != null)
        {
            return(_FixedUpdateStore.Contains(fixedUpdate));
        }

        ILateUpdate lateUpdate = _instance_ as ILateUpdate;

        if (lateUpdate != null)
        {
            return(_LateUpdateStore.Contains(lateUpdate));
        }

        return(false);
    }
Пример #4
0
 private void RemoveFixedUpdate(IFixedUpdate fixedUpdate)
 {
     if (_FixedUpdateStore.Contains(fixedUpdate))
     {
         _FixedUpdateStore.Remove(fixedUpdate);
         FixedUpdateStore = _FixedUpdateStore.ToArray();
     }
 }
Пример #5
0
            /// <summary>
            /// Removes a new that needs to be called every fixed framerate frame.
            /// </summary>
            /// <param name="update"></param>
            public void RemoveFixedUpdate(IFixedUpdate update)
            {
                // Don't do anything if the object will be destroyed.
                if (destroying)
                {
                    return;
                }

                FixedUpdateList.Remove(update);
            }
Пример #6
0
            /// <summary>
            /// Adds a new component that needs to be called every fixed framerate frame.
            /// </summary>
            /// <param name="update"></param>
            public void AddFixedUpdate(IFixedUpdate update)
            {
                // Don't do anything if the object will be destroyed.
                if (m_Destroying)
                {
                    return;
                }

                FixedUpdateList.Add(update);
            }
Пример #7
0
        public void AddFixedUpdater(IFixedUpdate fixedUpdater)
        {
#if DEBUG
            if (fixedUpdaters.Contains(fixedUpdater))
            {
                Debug.LogError("The updater has been added to the list");
                return;
            }
#endif
            fixedUpdaters.Add(fixedUpdater);
        }
 public static void RegisteIFixedUpdate(IFixedUpdate single)
 {
     if (single == null)
     {
         return;
     }
     if (!listFixedUpdate.Contains(single))
     {
         listFixedUpdate.Add(single);
     }
 }
 public static void UnRegisteIFixedUpdate(IFixedUpdate single)
 {
     if (single == null)
     {
         return;
     }
     if (listFixedUpdate.Contains(single))
     {
         listFixedUpdate.Remove(single);
     }
 }
 public static void FixUpdate()
 {
     for (int i = 0; i < listFixedUpdate.Count; i++)
     {
         IFixedUpdate single = listFixedUpdate[i];
         if (single != null)
         {
             UnityEngine.Profiling.Profiler.BeginSample(single.GetType() + "FixUpdate");
             single.OnFixedUpdate(UnityEngine.Time.deltaTime);
             UnityEngine.Profiling.Profiler.EndSample();
         }
     }
 }
        public void AddUpdate(IFixedUpdate target)
        {
            if (CheckNull(target))
            {
                return;
            }

            if (_targetsFixedUpdate.Exists(t => t == target))
            {
                return;
            }

            _targetsFixedUpdate.Add(target);
        }
Пример #12
0
        /// <summary>
        /// Removes a new that needs to be called every fixed framerate frame.
        /// </summary>
        /// <param name="update"></param>
        public static void RemoveFixedUpdate(IFixedUpdate update)
        {
            // Make sure the Update Manager isn't being used in the editor.
            if (!Application.isPlaying)
            {
                Debug.LogWarning("Update Manager can not be used outside the game!");
                return;
            }

            // Remove the update on the instance.
            if (UpdateManagerBehaviour.Instance)
            {
                UpdateManagerBehaviour.Instance.RemoveFixedUpdate(update);
            }
        }
Пример #13
0
 public static void RemoveFixedUpdateList(IFixedUpdate fixedUpdate)
 {
     fixedUpdates.Remove(fixedUpdate);
 }
Пример #14
0
 public static void AddFixedUpdateList(IFixedUpdate fixedUpdate)
 {
     fixedUpdates.Add(fixedUpdate);
 }
Пример #15
0
 public static void RemoveFixedUpdate(IFixedUpdate updater) => GetRunner().m_FixedUpdates.Remove(updater);
Пример #16
0
 public static void AddFixedUpdate(IFixedUpdate updater) => GetRunner().m_FixedUpdates.Add(updater);
Пример #17
0
 private void AddFixedUpdate(IFixedUpdate fixedUpdate)
 {
     _FixedUpdateStore.Add(fixedUpdate);
     FixedUpdateStore = _FixedUpdateStore.ToArray();
 }
 public void RemoveUpdate(IFixedUpdate target)
 {
     _targetsFixedUpdate.Remove(target);
 }
Пример #19
0
 internal void AddFixedUpdate(IFixedUpdate fixedUpdate)
 {
     _fixedUpdatesList.Add(fixedUpdate);
 }
Пример #20
0
 public static void AddFixedUpdate(IFixedUpdate updater) => sm_Updater?.m_FixedUpdates.Add(updater);
Пример #21
0
 public void RemoveFixedUpdater(IFixedUpdate fixedUpdater)
 {
     fixedUpdaters.Remove(fixedUpdater);
 }
Пример #22
0
 public static void RemoveFixedUpdate(IFixedUpdate updater) => sm_Updater?.m_FixedUpdates.Remove(updater);
Пример #23
0
 private void SetUpdates(AbstractStateBase abstractState)
 {
     _fixedUpdate = abstractState as IFixedUpdate;
     _lateUpdate  = abstractState as ILateUpdate;
     _update      = abstractState as IUpdate;
 }