Beispiel #1
0
        private void Update()
        {
            if (_timeScaleProperties.Count > 0)
            {
                _currentTimeScaleProperty = _timeScaleProperties.Peek();
                TargetTimeScale           = _currentTimeScaleProperty.TimeScale;
                LerpSpeed     = _currentTimeScaleProperty.LerpSpeed;
                LerpTimeScale = _currentTimeScaleProperty.Lerp;
                _currentTimeScaleProperty.Duration -= UnityEngine.Time.unscaledDeltaTime;

                _timeScaleProperties.Pop();
                _timeScaleProperties.Push(_currentTimeScaleProperty);

                if (_currentTimeScaleProperty.Duration <= 0 && !_currentTimeScaleProperty.Infinite)
                {
                    UnFreeze();
                }
            }
            else
            {
                TargetTimeScale = NormalTimeScale;
            }

            //Apply the Timescale
            if (LerpTimeScale)
            {
                UnityEngine.Time.timeScale = Mathf.Lerp(UnityEngine.Time.timeScale, TargetTimeScale, UnityEngine.Time.unscaledDeltaTime * LerpSpeed);
            }
            else
            {
                UnityEngine.Time.timeScale = TargetTimeScale;
            }

            CurrentTimeScale = UnityEngine.Time.timeScale;
        }
Beispiel #2
0
 public void SetTimeScale(TimeScaleProperties timeScaleProperties)
 {
     _timeScaleProperties.Push(timeScaleProperties);
 }