Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class DeltaTime : MonoBehaviour
- {
- private float deltaTime = 0;
- private float lastFrameTime = 0;
- private static DeltaTime instance;
- void Awake ()
- {
- instance = this;
- }
- void Update ()
- {
- deltaTime = Time.realtimeSinceStartup - lastFrameTime;
- lastFrameTime = Time.realtimeSinceStartup;
- }
- public static float get ()
- {
- return Time.timeScale == 1 ? Time.deltaTime : instance.deltaTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement