コード例 #1
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);
    }
コード例 #2
0
        public void LateUpdate()
        {
            while (this.lateUpdates.Count > 0)
            {
                Disposer disposer = this.lateUpdates.Dequeue();
                if (disposer.Id == 0)
                {
                    continue;
                }
                if (!this.disposerEvents.TryGetValue(disposer.GetType(), out IObjectEvent objectEvent))
                {
                    continue;
                }

                this.lateUpdates2.Enqueue(disposer);

                ILateUpdate iLateUpdate = objectEvent as ILateUpdate;
                if (iLateUpdate == null)
                {
                    continue;
                }
                objectEvent.Set(disposer);
                try
                {
                    iLateUpdate.LateUpdate();
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                }
            }

            ObjectHelper.Swap(ref this.lateUpdates, ref this.lateUpdates2);
        }
コード例 #3
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
    }
コード例 #4
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
    }
コード例 #5
0
 private void RemoveLateUpdate(ILateUpdate lateUpdate)
 {
     if (_LateUpdateStore.Contains(lateUpdate))
     {
         _LateUpdateStore.Remove(lateUpdate);
         LateUpdateStore = _LateUpdateStore.ToArray();
     }
 }
コード例 #6
0
        public static void RemoveLateUpdate(ILateUpdate update)
        {
            var _ = instance;

            while (lateUpdateList.Remove(update.OnLateUpdate))
            {
            }
        }
コード例 #7
0
        public static void AddLateUpdate(ILateUpdate update)
        {
            var _ = instance;

            if (!lateUpdateList.Contains(update.OnLateUpdate))
            {
                lateUpdateList.Add(update.OnLateUpdate);
            }
        }
コード例 #8
0
ファイル: UpdateManager.cs プロジェクト: Hertzole/HertzLib
            /// <summary>
            /// Removes a new that needs to be called every frame.
            /// </summary>
            /// <param name="update"></param>
            public void RemoveLateUpdate(ILateUpdate update)
            {
                // Don't do anything if the object will be destroyed.
                if (destroying)
                {
                    return;
                }

                LateUpdateList.Remove(update);
            }
コード例 #9
0
            /// <summary>
            /// Adds a new component that needs to be called every frame.
            /// </summary>
            /// <param name="update"></param>
            public void AddLateUpdate(ILateUpdate update)
            {
                // Don't do anything if the object will be destroyed.
                if (m_Destroying)
                {
                    return;
                }

                LateUpdateList.Add(update);
            }
コード例 #10
0
 public static void RegisteILateUpdate(ILateUpdate single)
 {
     if (single == null)
     {
         return;
     }
     if (!listLaterUpdate.Contains(single))
     {
         listLaterUpdate.Add(single);
     }
 }
コード例 #11
0
 public static void UnRegisteILateUpdate(ILateUpdate single)
 {
     if (single == null)
     {
         return;
     }
     if (listLaterUpdate.Contains(single))
     {
         listLaterUpdate.Remove(single);
     }
 }
コード例 #12
0
        public void AddLateUpdater(ILateUpdate lateUpdater)
        {
#if DEBUG
            if (lateUpdaters.Contains(lateUpdater))
            {
                Debug.LogError("The updater has been added to the list");
                return;
            }
#endif
            lateUpdaters.Add(lateUpdater);
        }
コード例 #13
0
        public void AddUpdate(ILateUpdate target)
        {
            if (CheckNull(target))
            {
                return;
            }

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

            _targetsLateUpdate.Add(target);
        }
コード例 #14
0
ファイル: UpdateManager.cs プロジェクト: Hertzole/HertzLib
        /// <summary>
        /// Removes a new that needs to be called every frame.
        /// </summary>
        /// <param name="update"></param>
        public static void RemoveLateUpdate(ILateUpdate 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.RemoveLateUpdate(update);
            }
        }
コード例 #15
0
        public static void LateUpdate(float ElapsedSeconds)
        {
            for (int i = 0; i < listLaterUpdate.Count; i++)
            {
                ILateUpdate single = listLaterUpdate[i];
                if (single != null)
                {
                    UnityEngine.Profiling.Profiler.BeginSample(single.GetType() + "LateUpdate");

                    single.OnLateUpdate(ElapsedSeconds);

                    UnityEngine.Profiling.Profiler.EndSample();
                }
            }
        }
コード例 #16
0
 private void RemoveUpdate(IBusiness removeItem)
 {
     if (removeItem is IUpdate)
     {
         IUpdate iupdate = removeItem as IUpdate;
         if (lisUpdate.Contains(iupdate))
         {
             lisUpdate.Remove(iupdate);
         }
     }
     if (removeItem is ILateUpdate)
     {
         ILateUpdate ilateUpdate = removeItem as ILateUpdate;
         if (lisLateUpdate.Contains(ilateUpdate))
         {
             lisLateUpdate.Remove(ilateUpdate);
         }
     }
 }
コード例 #17
0
ファイル: ObjectManager.cs プロジェクト: dqtoy/ActDemo
        public void LateUpdate()
        {
            unique.Clear();
            while (this.lateUpdates.Count > 0)
            {
                ObjectDisposer disposer = this.lateUpdates.Dequeue();
                if (disposer.IsDispose)
                {
                    continue;
                }

                if (!this.unique.Add(disposer))
                {
                    continue;
                }

                IObjectEventFacade objectSystem;
                if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectSystem))
                {
                    continue;
                }

                this.lateUpdates2.Enqueue(disposer);

                ILateUpdate iLateUpdate = objectSystem as ILateUpdate;
                if (iLateUpdate == null)
                {
                    continue;
                }
                objectSystem.Set(disposer);
                try
                {
                    iLateUpdate.LateUpdate();
                }
                catch (Exception e)
                {
                    Logger.LogError(e.ToString());
                }
            }

            ObjectHelper.Swap(ref this.lateUpdates, ref this.lateUpdates2);
        }
コード例 #18
0
        public void LateUpdate(float deltaTime)
        {
            while (this.lateUpdates.Count > 0)
            {
                ECS_Disposer disposer = this.lateUpdates.Dequeue();
                if (disposer.Id == 0)
                {
                    continue;
                }

                IObjectEvent objectEvent;
                if (!this.disposerEvents.TryGetValue(disposer.GetType(), out objectEvent))
                {
                    continue;
                }

                this.lateUpdates2.Enqueue(disposer);

                ILateUpdate iLateUpdate = objectEvent as ILateUpdate;
                if (iLateUpdate == null)
                {
                    continue;
                }
                objectEvent.Set(disposer);
#if UNITY_EDITOR
                iLateUpdate.LateUpdate(deltaTime);
#else
                try
                {
                    iLateUpdate.LateUpdate(deltaTime);
                }
                catch (Exception e)
                {
                    Logger.LogError(e.ToString());
                }
#endif
            }

            ObjectHelper.Swap(ref this.lateUpdates, ref this.lateUpdates2);
        }
コード例 #19
0
 public static void AddLateUpdate(ILateUpdate updater) => sm_Updater?.m_LateUpdates.Add(updater);
コード例 #20
0
 public void RemoveLateUpdater(ILateUpdate lateUpdater)
 {
     lateUpdaters.Remove(lateUpdater);
 }
コード例 #21
0
 public void RemoveUpdate(ILateUpdate target)
 {
     _targetsLateUpdate.Remove(target);
 }
コード例 #22
0
 private void AddLateUpdate(ILateUpdate lateUpdate)
 {
     _LateUpdateStore.Add(lateUpdate);
     LateUpdateStore = _LateUpdateStore.ToArray();
 }
コード例 #23
0
 /// <summary>
 /// Unregister an object from Late update.
 /// </summary>
 public void Unregister(ILateUpdate _update) => lateUpdates.Remove(_update);
コード例 #24
0
        // ------------------------------

        /// <summary>
        /// Register an object on Late update.
        /// </summary>
        public void Register(ILateUpdate _update) => lateUpdates.Add(_update);
コード例 #25
0
 public static void RemoveLateUpdate(ILateUpdate updater) => GetRunner().m_LateUpdates.Remove(updater);
コード例 #26
0
 public static void AddLateUpdate(ILateUpdate updater) => GetRunner().m_LateUpdates.Add(updater);
コード例 #27
0
 public static void RemoveLateUpdate(ILateUpdate updater) => sm_Updater?.m_LateUpdates.Remove(updater);
コード例 #28
0
 public static void Remove(ILateUpdate handler)
 {
     self.lateUpdates.Remove(handler);
     self.count = self.lateUpdates.Count;
 }
コード例 #29
0
 private void SetUpdates(AbstractStateBase abstractState)
 {
     _fixedUpdate = abstractState as IFixedUpdate;
     _lateUpdate  = abstractState as ILateUpdate;
     _update      = abstractState as IUpdate;
 }