From 93c44d20cd0c91723a4f181796775242a03501ae Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 13 Nov 2025 23:39:45 -0700 Subject: [PATCH] Fix event timestamps not aligning to actual real time In the editor, the input system uses an internal time offset which is adjusted whenever play mode is entered or exited. This offset is used to make the 0 point of input timestamps match the time at which the last play mode transition happened. The current method of grabbing input time bypasses this offset by using reflection to access an internal property. Without this offset, timestamps will never be in sync while in the editor, and will continually drift more and more each time play mode is entered. The publicly-accessible `InputState.currentTime` property accounts for this offset, and so do the `InputSystem.Queue*Event` family of functions. Using that instead fixes this issue. --- .../jp.keijiro.minis/Runtime/Internal/MidiUtility.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Packages/jp.keijiro.minis/Runtime/Internal/MidiUtility.cs b/Packages/jp.keijiro.minis/Runtime/Internal/MidiUtility.cs index d582d07..39ad389 100644 --- a/Packages/jp.keijiro.minis/Runtime/Internal/MidiUtility.cs +++ b/Packages/jp.keijiro.minis/Runtime/Internal/MidiUtility.cs @@ -1,7 +1,5 @@ -using System; -using System.Reflection; -using UnityEngine; using UnityEngine.InputSystem.Layouts; +using UnityEngine.InputSystem.LowLevel; namespace Minis { @@ -29,13 +27,7 @@ public static int // Access to the internal current time property in Input System public static double GetTime() - { - var inputSystemType = Type.GetType - ("UnityEngineInternal.Input.NativeInputSystem, UnityEngine"); - var currentTimeProperty = inputSystemType.GetProperty - ("currentTime", BindingFlags.Public | BindingFlags.Static); - return (double)currentTimeProperty.GetValue(null); - } + => InputState.currentTime; } } // namespace Minis