public static ManagedUpdate AddManagedUpdate(object targetClass, ManagedUpdate updater)
 {
     updater = new ManagedUpdate(targetClass);
     updates.Add(updater);
     numUpdates++;
     return(updater);
 }
Beispiel #2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != this)
     {
         Debug.Log("Multiple instances of ManagedUpdate in the scene. Destroying duplicates.");
         Destroy(this);
     }
 }
Beispiel #3
0
        private static float GetTime(int updateLoopId, bool unscaled)
        {
            float currentTime;

            if (updateLoopId == ManagedUpdate.EventIds.FixedUpdate ||
                ManagedUpdate.GetParentLoopForid(updateLoopId) == UpdateLoop.FixedUpdate)
            {
                currentTime = unscaled
                    ? BetterTime.FixedUnscaledTime
                    : BetterTime.FixedTime;
            }
            else
            {
                currentTime = unscaled
                    ? BetterTime.UnscaledTime
                    : BetterTime.Time;
            }

            return(currentTime);
        }
Beispiel #4
0
        private static void Start(BetterCoroutine coroutine)
        {
            var scaledTime   = GetTime(coroutine.UpdateLoopId, false);
            var unscaledTime = GetTime(coroutine.UpdateLoopId, true);

            IdToCoroutine[coroutine.Id] = coroutine;

            var list = GetList(coroutine.UpdateLoopId);

            if (list == null)
            {
                UpdateLoopToCoroutines[coroutine.UpdateLoopId] = list = new PooledLinkedList <BetterCoroutine>(SharedNodePool);
                ManagedUpdate.AddListener(coroutine.UpdateLoopId, Instance);
            }

            var node = list.AddFirst(coroutine);

            var prevCurrent = _current;

            _current = node;

            var continueRunning = UpdateCoroutine(scaledTime, unscaledTime, coroutine);

            if (!continueRunning)
            {
                IdToCoroutine.Remove(coroutine.Id);
                list.Remove(coroutine);
                if (coroutine.Parent != null)
                {
                    coroutine.Parent.Child = null;
                }
                PoolHelper <BetterCoroutine> .Despawn(coroutine);
            }

            _current = prevCurrent;
        }
 protected void Subscribe_LateUpdate()
 {
     ManagedUpdate.Subscribe(this);
 }
 protected void Unsubscribe_Update()
 {
     ManagedUpdate.Unsubscribe(this);
 }
Beispiel #7
0
 private void OnDisable()
 {
     ManagedUpdate.Unsubscribe(ManagedUpdate.Queue.Ping, new ManagedUpdate.OnUpdate(UpdateBlips));
 }