realtimeSinceStartupAsDouble
The real time in seconds since the game started (Read Only). Double precision version of Time.realtimeSinceStartup.
Read time 2 minutesLast updated 13 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static double realtimeSinceStartupAsDouble { get; }
Remarks
This property is the time in seconds since the start of the application and isn't constant if called multiple times in a frame. Time.timeScale doesn't affect this property. In almost all cases, use over . offers more precision, particularly over extended periods of real-world time.
realtimeSinceStartupAsDoublerealtimeSinceStartuprealtimeSinceStartupAsDoubleIn most use cases, use Time.time, Time.timeAsDouble, Time.unscaledTime, or Time.unscaledTimeAsDouble instead of this property. However, is useful if you want to set to zero to pause your application, but you also still want to measure time. In Editor scripts, you can also use to measure time while the Editor is paused.
realtimeSinceStartupAsDoubletimeScalerealtimeSinceStartupAsDoublerealtimeSinceStartupAsDoubleNOTE: There is a known issue where and OnDestroy@@.
realtimeSinceStartuprealtimeSinceStartupAsDouble return incorrect values when using Examples
using UnityEngine;using System.Collections;// An FPS counter.// It calculates frames/second over each updateInterval,// so the display does not keep changing wildly.public class ExampleClass : MonoBehaviour{ public float updateInterval = 0.5F; private double lastInterval; private int frames = 0; private float fps; void Start() { lastInterval = Time.realtimeSinceStartupAsDouble; frames = 0; } void OnGUI() { GUILayout.Label("" + fps.ToString("f2")); } void Update() { ++frames; double timeNow = Time.realtimeSinceStartupAsDouble; if (timeNow > lastInterval + updateInterval) { fps = (float)(frames / (timeNow - lastInterval)); frames = 0; lastInterval = timeNow; } }}