EXACTLY, they should have had it day 1.
Add this script to your /assets/Editor folder and you get the functionality by pressing f11 instead of play:
Of course, turn off asset refresh. This will give you an extra half hour of productivity per day.
using System;
using System.IO;
using System.Text;
//using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEditor;
using UnityEngine.Events;
using UnityEngine.Scripting;
using UnityEditorInternal;
using UnityEditor.Scripting;
using UnityEngine.TestTools;
using Unity.Profiling;
using UnityEditor.Profiling;
//using UnityEngine.SceneManagement;
using UnityEditor.VersionControl;
using UnityEngine.Profiling;
using System.Reflection;
public static class GlobalKeyEvents
{
// Exposed delegates to hook up your methods to them.
public static event Action<KeyCode, EventModifiers> GlobalKeyDown;
public static event Action<KeyCode, EventModifiers> GlobalKeyUp;
public static event Action AnyShortcutTriggered;
[InitializeOnLoadMethod]
private static void EditorInit()
{
RegisterToGlobalEventHandler();
RegisterToTriggeredAnyShortcut();
}
private static bool OnAnyShortcutTriggered()
{
AnyShortcutTriggered?.Invoke();
return true;
}
private static void RegisterToGlobalEventHandler()
{
FieldInfo info = typeof(EditorApplication).GetField(“globalEventHandler”, BindingFlags.Static | BindingFlags.NonPublic);
EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null);
value += OnGlobalKeyPressed;
info.SetValue(null, value);
}
private static void RegisterToTriggeredAnyShortcut()
{
FieldInfo info = typeof(EditorApplication).GetField(“doPressedKeysTriggerAnyShortcut”, BindingFlags.Static | BindingFlags.NonPublic);
Func value = (Func)info.GetValue(null);
value += OnAnyShortcutTriggered;
info.SetValue(null, value);
}
private static void OnGlobalKeyPressed()
{
if (Event.current.type == EventType.KeyDown)
{
KeyCode key1 = Event.current.keyCode;
switch (key1)
{
case KeyCode.W:
//Debug.Log(“W!”);
break;
case KeyCode.F12:
case KeyCode.F11:
//case KeyCode.F10:
case KeyCode.F9:
{
if (Application.isPlaying)
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
else
{
UnityEditor.AssetDatabase.Refresh();
UnityEditor.EditorApplication.EnterPlaymode();
}
}
break;
}
GlobalKeyDown?.Invoke(Event.current.keyCode, Event.current.modifiers);
}
else if (Event.current.type == EventType.KeyUp)
{
GlobalKeyUp?.Invoke(Event.current.keyCode, Event.current.modifiers);
}
}
/*
public class DisableUnityMenuItems : Editor
{
[MenuItem(“MainMenu/Edit/Play”)]
static void aa()
{
}
}
*/
}