From 7ce73186aef072db953e543c153e422ba5ff5593 Mon Sep 17 00:00:00 2001 From: PopSlime Date: Mon, 14 Nov 2022 13:49:29 +0800 Subject: [PATCH] Make Unity timestamps realtime critical. (2) --- Assets/Cryville/Common/Unity/Input/UnityKeyHandler.cs | 6 +++--- Assets/Cryville/Common/Unity/Input/UnityMouseHandler.cs | 2 +- Assets/Cryville/Common/Unity/Input/UnityTouchHandler.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/Cryville/Common/Unity/Input/UnityKeyHandler.cs b/Assets/Cryville/Common/Unity/Input/UnityKeyHandler.cs index e728d71..43f1e12 100644 --- a/Assets/Cryville/Common/Unity/Input/UnityKeyHandler.cs +++ b/Assets/Cryville/Common/Unity/Input/UnityKeyHandler.cs @@ -50,7 +50,7 @@ namespace Cryville.Common.Unity.Input { } public abstract string GetKeyName(int type); void Update() { - double time = Time.timeAsDouble; + double time = Time.realtimeSinceStartupAsDouble; foreach (var k in Keys) { Callback(k, 0, new InputVector(time, Vector3.zero)); } @@ -64,7 +64,7 @@ namespace Cryville.Common.Unity.Input { void OnGUI() { var e = Event.current; if (e.keyCode == KeyCode.None) return; - double time = Time.timeAsDouble; + double time = Time.realtimeSinceStartupAsDouble; var key = (int)e.keyCode; switch (e.type) { case EventType.KeyDown: @@ -92,7 +92,7 @@ namespace Cryville.Common.Unity.Input { } void OnGUI() { var e = Event.current; - double time = Time.timeAsDouble; + double time = Time.realtimeSinceStartupAsDouble; var key = e.button; switch (e.type) { case EventType.MouseDown: diff --git a/Assets/Cryville/Common/Unity/Input/UnityMouseHandler.cs b/Assets/Cryville/Common/Unity/Input/UnityMouseHandler.cs index f608abd..793a20b 100644 --- a/Assets/Cryville/Common/Unity/Input/UnityMouseHandler.cs +++ b/Assets/Cryville/Common/Unity/Input/UnityMouseHandler.cs @@ -54,7 +54,7 @@ namespace Cryville.Common.Unity.Input { handler = h; } void Update() { - double time = Time.timeAsDouble; + double time = Time.realtimeSinceStartupAsDouble; Vector3 pos = UnityCameraUtils.ScreenToWorldPoint(unity::Input.mousePosition); handler.Feed(0, 0, new InputVector(time, pos)); } diff --git a/Assets/Cryville/Common/Unity/Input/UnityTouchHandler.cs b/Assets/Cryville/Common/Unity/Input/UnityTouchHandler.cs index 2c73096..7cfaa11 100644 --- a/Assets/Cryville/Common/Unity/Input/UnityTouchHandler.cs +++ b/Assets/Cryville/Common/Unity/Input/UnityTouchHandler.cs @@ -54,7 +54,7 @@ namespace Cryville.Common.Unity.Input { handler = h; } void Update() { - double time = Time.timeAsDouble; + double time = Time.realtimeSinceStartupAsDouble; for (int i = 0; i < unity::Input.touchCount; i++) { var t = unity::Input.GetTouch(i); Vector2 pos = UnityCameraUtils.ScreenToWorldPoint(t.position);