Feel  5.1
The best way to improve your game's feel and make it extra juicy
MoreMountains.Feedbacks.MMTimeManager Class Reference

Put this component in your scene and it'll catch MMFreezeFrameEvents and MMTimeScaleEvents, allowing you to control the flow of time. More...

Inheritance diagram for MoreMountains.Feedbacks.MMTimeManager:
MoreMountains.Tools.MMSingleton< MMTimeManager >

Public Member Functions

virtual void PreInitialization ()
 We initialize our stack More...
 
virtual void Initialization ()
 On init we store our initial timescales and apply the normal timescale More...
 
virtual void SetTimeScaleTo (float newNormalTimeScale)
 Sets the time scale to the specified value, instantly More...
 
virtual void OnTimeScaleEvent (MMTimeScaleMethods timeScaleMethod, float timeScale, float duration, bool lerp, float lerpSpeed, bool infinite, MMTimeScaleLerpModes timeScaleLerpMode=MMTimeScaleLerpModes.Speed, MMTweenType timeScaleLerpCurve=null, float timeScaleLerpDuration=0.2f, bool timeScaleLerpOnReset=false, MMTweenType timeScaleLerpCurveOnReset=null, float timeScaleLerpDurationOnReset=0.2f)
 Catches TimeScaleEvents and acts on them More...
 
virtual void OnMMFreezeFrameEvent (float duration)
 When getting a freeze frame event we stop the time More...
 

Public Attributes

float NormalTimeScale = 1f
 The reference time scale, to which the system will go back to after all time is changed. More...
 
bool UpdateTimescale = true
 whether or not to update Time.timeScale when changing time scale More...
 
bool UpdateFixedDeltaTime = true
 whether or not to update Time.fixedDeltaTime when changing time scale More...
 
bool UpdateMaximumDeltaTime = true
 whether or not to update Time.maximumDeltaTime when changing time scale More...
 
float CurrentTimeScale = 1f
 the current, real time, time scale More...
 
float TargetTimeScale = 1f
 the time scale the system is lerping towards More...
 
bool TestButton
 a test button for the inspector More...
 

Protected Member Functions

virtual void TestButtonToSlowDownTime ()
 A method used from the inspector to test the system More...
 
override void Awake ()
 On start we initialize our stack More...
 
virtual void Start ()
 On Start we apply our timescale More...
 
virtual void Update ()
 On Update, applies the time scale and resets it if needed More...
 
virtual void ApplyTimeScale (float newValue)
 Modifies the time scale and time attributes to match the new time scale More...
 
virtual void SetTimeScale (float newTimeScale)
 Resets all stacked time scale changes and simply sets the time scale, until further changes More...
 
virtual void SetTimeScale (TimeScaleProperties timeScaleProperties)
 Sets the time scale for the specified properties (duration, time scale, lerp or not, and lerp speed) More...
 
virtual void ResetTimeScale ()
 Resets the time scale to the stored normal time scale More...
 
virtual void Unfreeze ()
 Resets the time scale to the last saved time scale. More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMSingleton< MMTimeManager >
virtual void InitializeSingleton ()
 Initializes the singleton. More...
 

Static Protected Member Functions

static void InitializeStatics ()
 Statics initialization to support enter play modes More...
 

Protected Attributes

Stack< TimeScaleProperties_timeScaleProperties
 
TimeScaleProperties _currentProperty
 
TimeScaleProperties _resetProperty
 
float _initialFixedDeltaTime = 0f
 
float _initialMaximumDeltaTime = 0f
 
float _startedAt
 
bool _lerpingBackToNormal = false
 
float _timeScaleLastTime = float.NegativeInfinity
 

Additional Inherited Members

- Static Public Member Functions inherited from MoreMountains.Tools.MMSingleton< MMTimeManager >
static T TryGetInstance ()
 
- Static Public Attributes inherited from MoreMountains.Tools.MMSingleton< MMTimeManager >
static bool HasInstance
 
static T Current
 
- Static Protected Attributes inherited from MoreMountains.Tools.MMSingleton< MMTimeManager >
static T _instance
 
- Properties inherited from MoreMountains.Tools.MMSingleton< MMTimeManager >
static T Instance [get]
 Singleton design pattern More...
 

Detailed Description

Put this component in your scene and it'll catch MMFreezeFrameEvents and MMTimeScaleEvents, allowing you to control the flow of time.

Member Function Documentation

◆ ApplyTimeScale()

virtual void MoreMountains.Feedbacks.MMTimeManager.ApplyTimeScale ( float  newValue)
protectedvirtual

Modifies the time scale and time attributes to match the new time scale

Parameters
newValue

◆ Awake()

override void MoreMountains.Feedbacks.MMTimeManager.Awake ( )
protectedvirtual

On start we initialize our stack

Reimplemented from MoreMountains.Tools.MMSingleton< MMTimeManager >.

◆ Initialization()

virtual void MoreMountains.Feedbacks.MMTimeManager.Initialization ( )
virtual

On init we store our initial timescales and apply the normal timescale

◆ InitializeStatics()

static void MoreMountains.Feedbacks.MMTimeManager.InitializeStatics ( )
staticprotected

Statics initialization to support enter play modes

◆ OnMMFreezeFrameEvent()

virtual void MoreMountains.Feedbacks.MMTimeManager.OnMMFreezeFrameEvent ( float  duration)
virtual

When getting a freeze frame event we stop the time

Parameters
freezeFrameEventFreeze frame event.

◆ OnTimeScaleEvent()

virtual void MoreMountains.Feedbacks.MMTimeManager.OnTimeScaleEvent ( MMTimeScaleMethods  timeScaleMethod,
float  timeScale,
float  duration,
bool  lerp,
float  lerpSpeed,
bool  infinite,
MMTimeScaleLerpModes  timeScaleLerpMode = MMTimeScaleLerpModes.Speed,
MMTweenType  timeScaleLerpCurve = null,
float  timeScaleLerpDuration = 0.2f,
bool  timeScaleLerpOnReset = false,
MMTweenType  timeScaleLerpCurveOnReset = null,
float  timeScaleLerpDurationOnReset = 0.2f 
)
virtual

Catches TimeScaleEvents and acts on them

Parameters
timeScaleEventMMTimeScaleEvent event.

◆ PreInitialization()

virtual void MoreMountains.Feedbacks.MMTimeManager.PreInitialization ( )
virtual

We initialize our stack

◆ ResetTimeScale()

virtual void MoreMountains.Feedbacks.MMTimeManager.ResetTimeScale ( )
protectedvirtual

Resets the time scale to the stored normal time scale

◆ SetTimeScale() [1/2]

virtual void MoreMountains.Feedbacks.MMTimeManager.SetTimeScale ( float  newTimeScale)
protectedvirtual

Resets all stacked time scale changes and simply sets the time scale, until further changes

Parameters
newTimeScaleNew time scale.

◆ SetTimeScale() [2/2]

virtual void MoreMountains.Feedbacks.MMTimeManager.SetTimeScale ( TimeScaleProperties  timeScaleProperties)
protectedvirtual

Sets the time scale for the specified properties (duration, time scale, lerp or not, and lerp speed)

Parameters
timeScalePropertiesTime scale properties.

◆ SetTimeScaleTo()

virtual void MoreMountains.Feedbacks.MMTimeManager.SetTimeScaleTo ( float  newNormalTimeScale)
virtual

Sets the time scale to the specified value, instantly

Parameters
newNormalTimeScaleNew normal time scale.

◆ Start()

virtual void MoreMountains.Feedbacks.MMTimeManager.Start ( )
protectedvirtual

On Start we apply our timescale

◆ TestButtonToSlowDownTime()

virtual void MoreMountains.Feedbacks.MMTimeManager.TestButtonToSlowDownTime ( )
protectedvirtual

A method used from the inspector to test the system

◆ Unfreeze()

virtual void MoreMountains.Feedbacks.MMTimeManager.Unfreeze ( )
protectedvirtual

Resets the time scale to the last saved time scale.

◆ Update()

virtual void MoreMountains.Feedbacks.MMTimeManager.Update ( )
protectedvirtual

On Update, applies the time scale and resets it if needed

Member Data Documentation

◆ _currentProperty

TimeScaleProperties MoreMountains.Feedbacks.MMTimeManager._currentProperty
protected

◆ _initialFixedDeltaTime

float MoreMountains.Feedbacks.MMTimeManager._initialFixedDeltaTime = 0f
protected

◆ _initialMaximumDeltaTime

float MoreMountains.Feedbacks.MMTimeManager._initialMaximumDeltaTime = 0f
protected

◆ _lerpingBackToNormal

bool MoreMountains.Feedbacks.MMTimeManager._lerpingBackToNormal = false
protected

◆ _resetProperty

TimeScaleProperties MoreMountains.Feedbacks.MMTimeManager._resetProperty
protected

◆ _startedAt

float MoreMountains.Feedbacks.MMTimeManager._startedAt
protected

◆ _timeScaleLastTime

float MoreMountains.Feedbacks.MMTimeManager._timeScaleLastTime = float.NegativeInfinity
protected

◆ _timeScaleProperties

Stack<TimeScaleProperties> MoreMountains.Feedbacks.MMTimeManager._timeScaleProperties
protected

◆ CurrentTimeScale

float MoreMountains.Feedbacks.MMTimeManager.CurrentTimeScale = 1f

the current, real time, time scale

◆ NormalTimeScale

float MoreMountains.Feedbacks.MMTimeManager.NormalTimeScale = 1f

The reference time scale, to which the system will go back to after all time is changed.

◆ TargetTimeScale

float MoreMountains.Feedbacks.MMTimeManager.TargetTimeScale = 1f

the time scale the system is lerping towards

◆ TestButton

bool MoreMountains.Feedbacks.MMTimeManager.TestButton

a test button for the inspector

◆ UpdateFixedDeltaTime

bool MoreMountains.Feedbacks.MMTimeManager.UpdateFixedDeltaTime = true

whether or not to update Time.fixedDeltaTime when changing time scale

◆ UpdateMaximumDeltaTime

bool MoreMountains.Feedbacks.MMTimeManager.UpdateMaximumDeltaTime = true

whether or not to update Time.maximumDeltaTime when changing time scale

◆ UpdateTimescale

bool MoreMountains.Feedbacks.MMTimeManager.UpdateTimescale = true

whether or not to update Time.timeScale when changing time scale


The documentation for this class was generated from the following file: