/// <inheritdoc /> public virtual void OnEvent(int eventId) { switch (eventId) { case ManagedUpdate.EventIds.Update: _updateable.OnUpdate(); return; case ManagedUpdate.EventIds.LateUpdate: _lateUpdateable.OnLateUpdate(); return; case ManagedUpdate.EventIds.FixedUpdate: _fixedUpdateable.OnFixedUpdate(); return; } if (_customUpdateIds != null) { for (var i = 0; i < _customUpdateIds.Length; i++) { if (_customUpdateIds[i] != eventId) { continue; } _customUpdateable.OnCustomUpdate(eventId); return; } } }
/// <inheritdoc /> public virtual void OnEvent(int eventId) { switch (eventId) { case EventIds.Update: _updateable.OnUpdate(); return; case EventIds.LateUpdate: _lateUpdateable.OnLateUpdate(); return; case EventIds.FixedUpdate: _fixedUpdateable.OnFixedUpdate(); return; } }
//This should be the game's only MonoBehaviour Update method private void Update() { //Run all custom update methods if (!isPaused && updateableObjects != null) { float dt = Time.deltaTime; //Iterate through all objects backwards in case one object decides to destroy itself for (int i = updateableObjects.Count - 1; i >= 0; i--) { IUpdateable updateableObj = updateableObjects[i]; updateableObj.OnUpdate(dt); } } //Pause-unpause if (Input.GetKeyDown(KeyCode.Space)) { isPaused = !isPaused; } }