Make Unity timestamps realtime critical. (2)

This commit is contained in:
2022-11-14 13:49:29 +08:00
parent 318a6705be
commit 7ce73186ae
3 changed files with 5 additions and 5 deletions

View File

@@ -50,7 +50,7 @@ namespace Cryville.Common.Unity.Input {
} }
public abstract string GetKeyName(int type); public abstract string GetKeyName(int type);
void Update() { void Update() {
double time = Time.timeAsDouble; double time = Time.realtimeSinceStartupAsDouble;
foreach (var k in Keys) { foreach (var k in Keys) {
Callback(k, 0, new InputVector(time, Vector3.zero)); Callback(k, 0, new InputVector(time, Vector3.zero));
} }
@@ -64,7 +64,7 @@ namespace Cryville.Common.Unity.Input {
void OnGUI() { void OnGUI() {
var e = Event.current; var e = Event.current;
if (e.keyCode == KeyCode.None) return; if (e.keyCode == KeyCode.None) return;
double time = Time.timeAsDouble; double time = Time.realtimeSinceStartupAsDouble;
var key = (int)e.keyCode; var key = (int)e.keyCode;
switch (e.type) { switch (e.type) {
case EventType.KeyDown: case EventType.KeyDown:
@@ -92,7 +92,7 @@ namespace Cryville.Common.Unity.Input {
} }
void OnGUI() { void OnGUI() {
var e = Event.current; var e = Event.current;
double time = Time.timeAsDouble; double time = Time.realtimeSinceStartupAsDouble;
var key = e.button; var key = e.button;
switch (e.type) { switch (e.type) {
case EventType.MouseDown: case EventType.MouseDown:

View File

@@ -54,7 +54,7 @@ namespace Cryville.Common.Unity.Input {
handler = h; handler = h;
} }
void Update() { void Update() {
double time = Time.timeAsDouble; double time = Time.realtimeSinceStartupAsDouble;
Vector3 pos = UnityCameraUtils.ScreenToWorldPoint(unity::Input.mousePosition); Vector3 pos = UnityCameraUtils.ScreenToWorldPoint(unity::Input.mousePosition);
handler.Feed(0, 0, new InputVector(time, pos)); handler.Feed(0, 0, new InputVector(time, pos));
} }

View File

@@ -54,7 +54,7 @@ namespace Cryville.Common.Unity.Input {
handler = h; handler = h;
} }
void Update() { void Update() {
double time = Time.timeAsDouble; double time = Time.realtimeSinceStartupAsDouble;
for (int i = 0; i < unity::Input.touchCount; i++) { for (int i = 0; i < unity::Input.touchCount; i++) {
var t = unity::Input.GetTouch(i); var t = unity::Input.GetTouch(i);
Vector2 pos = UnityCameraUtils.ScreenToWorldPoint(t.position); Vector2 pos = UnityCameraUtils.ScreenToWorldPoint(t.position);