Click or drag to resize

BetterTime Class

A simple wrapper for Unity's Time that caches values to avoid the marshal overhead of each call. The performance benefit is very small, but completely free. Only readonly Time properties (except for FixedDeltaTime) are cached, but everything is wrapped anyway so you don't have to use multiple time classes. Since this is just a wrapper just refer to Unity's documentation about what each property does.
Inheritance Hierarchy
SystemObject
  Archon.SwissArmyLib.UtilsBetterTime

Namespace:  Archon.SwissArmyLib.Utils
Assembly:  Archon.SwissArmyLib (in Archon.SwissArmyLib.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static class BetterTime
Request Example View Source

The BetterTime type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberCaptureFramerate
Slows game playback time to allow screenshots to be saved between frames.
Public propertyStatic memberDeltaTime
Gets the difference in seconds since the last frame. (Scaled according to TimeScale)
Public propertyStatic memberFixedDeltaTime
Gets or sets the fixed time in seconds between FixedUpdate.
Public propertyStatic memberFixedTime
Gets the time that the latest FixedUpdate started. This is scaled according to TimeScale.
Public propertyStatic memberFixedUnscaledDeltaTime
Gets the unscaled time difference since the previous FixedUpdate.
Public propertyStatic memberFixedUnscaledTime
Gets the unscaled time that the latest FixedUpdate started.
Public propertyStatic memberFrameCount
Gets the total number of frames that have passed.
Public propertyStatic memberInFixedTimeStep
Gets whether we're inside a FixedUpdate at the moment.
Public propertyStatic memberMaximumDeltaTime
Gets or sets the maximum time in seconds that a fixed timestep frame can take.
Public propertyStatic memberMaximumParticleDeltaTime
Gets or sets the maximum time in seconds that a frame can spend on updating particles.
Public propertyStatic memberRealTimeSinceStartup
Gets the real time in seconds since the game started.
Public propertyStatic memberSmoothDeltaTime
Gets a smoothed out time difference in seconds since the last frame. (Scaled according to TimeScale)
Public propertyStatic memberTime
Gets the (scaled) time in seconds at the beginning of this frame.
Public propertyStatic memberTimeScale
Gets or sets the scalar that is applied to Time, DeltaTime etc.
Public propertyStatic memberTimeSinceLevelLoad
Gets the time since the last level was loaded.
Public propertyStatic memberUnscaledDeltaTime
Gets the unscaled time difference in seconds since the last frame.
Public propertyStatic memberUnscaledTime
Gets the unscaled time in seconds at the beginning of this frame.
Top
See Also