Detect Unity Editor Step Button Click Without Using of Unity's Time Class

Hello!

How would I detect use of the Unity editor’s “Step” button/menu item/keyboard shortcut without use of Unity’s Time class?

I have created a custom PlayerLoop to allow for the manual triggering of script Update() methods. I am trying to identify when the Unity Editor’s “Step” method has been called to trigger so as to manually trigger Update() methods when that occurs. My custom PlayerLoop does not include Unity’s native Initialization.PlayerUpdateTime PlayerLoopSystem, which prevents Unity’s Time class from being updated and thus renders variables such as Time.frameCount useless.

Currently, I am using Application.isPlaying && !EditorApplication.isPaused to prevent the PlayerLoop from updating scripts when the editor is not playing/paused, but this also prevents the “Step” method from working.

For reference, I am seeking to code this in C#, and I am using Unity v2018.2.0b2 with the Scripting Runtime Version “.NET 4.x Equivalent”.

Any assistance with solving this challenge is much appreciated!

Thank you in advance, and be well!

  • S.

I’m not sure why you don’t want to use the Time class, unless you mean that you are attempting to make your own time control instead of relying on Time class.

If that is the case, the way to detect that the Step button has been pressed is:

bool stepButtonPressed = UnityEditor.EditorApplication.isPaused && Time.deltaTime > 0f;