timeAsDouble
The double precision time at the beginning of this frame (Read Only). This is the time in seconds since the start of the game.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public static double timeAsDouble { get; }
Remarks
Time.timeAsDoubleThis is the double precision version of Time.time. It offers more precision than a float or single value, particularly over extended periods of real-world time. In most cases, prefer Time.timeAsDouble over Time.time for greater precision.
The application receives the current at the beginning of each frame, with the value increasing per frame. A call per frame receives the same value. When called from it returns the Time.fixedTimeAsDouble property.
Time.timeAsDoubletimeAsDoubleFixedUpdateYou can use for timestamping and measuring elapsed durations relative to the start of the application. For duration of the current frame and related per-frame accumulation or simulation steps, use Time.deltaTime instead.
Time.timeAsDoubleThe value of is undefined during messages and starts after all messages are finished. does not update if the Editor is paused. For a time value unaffected by pausing, refer to Time.realtimeSinceStartupAsDouble.
Time.timeAsDoubleAwakeTime.timeAsDoubleExamples
//If the Fire1 button is pressed, a projectile//will be Instantiated every 0.5 seconds.using UnityEngine;using System.Collections;public class Example : MonoBehaviour{ public GameObject projectile; public float fireRate = 0.5f; private double nextFire = 0.0f; void Update() { if (Input.GetButton("Fire1") && Time.timeAsDouble > nextFire) { nextFire = Time.timeAsDouble + fireRate; Instantiate(projectile, transform.position, transform.rotation); } }}