Hello! I wanna make editor-only hotkey using Shortcuts, to Toggle ‘Slow motion’ using Time.timeScale.
Code is simple, but it work in any other window, except GameView.
using UnityEditor.ShortcutManagement;
using UnityEngine;
namespace Plugins.mitaywalle.Editor
{
public class SlowMoShortcuts
{
[Shortcut("Debug/Toggle SlowMo", KeyCode.F6)]
public static void ToggleSlowMo()
{
Debug.Log("Toggle slow mo");
if (Time.timeScale == 1)
{
Time.timeScale = .25f;
}
else
{
Time.timeScale = 1;
}
}
}
}
I understand, that there may be conflicts with UnityEngine.Input and Unity.InputSystem, project use both.
My Custom Shortcut for ‘Main Menu/Edit/Pause’/‘Unpause’ work in GameView.
I don’t want to use MonoBehavior.Update() or EditorApplication.update for this. Is this possible using Shortcut system only?
I’m not sure you can get there from here… a lot of stuff gets “eaten” by the play screen when the game is running, stuff that otherwise works in the Game window when not running. For instance zoom in/out with mouse wheel in Game works when the editor is not running, but fails when running.
If you have any class in your game that ALWAYS starts up, I would put an editor-only singleton-creator that starts up an instance of the above. Make the above a MonoBehaviour that has Update() and watches for your key… that way when Game doesn’t have focus the key binding should work, but when Game has focus the Update() will catch it. Might not be 100% seamless but oughta be pretty slick.