Follow

Enter Play Mode with F5 key

Symptoms
  • I would like to enter Play Mode with F5 key.
Cause
 
There is no one-key keyboard shortcut to enter Play Mode and you can not intercept built-in Unity keyboard shortcuts.
 
Resolution
You can define your own keyboard shortcuts to do what you want. In the sample Editor script below, you can see how to detect the F5 key and enter Play Mode.
 
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;

public class EditorShortCutKeys : ScriptableObject {
[MenuItem("Edit/Run _F5")] // shortcut key F5 to Play (and exit playmode also) static void PlayGame() { if (!Application.isPlaying) { EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), "", false); } EditorApplication.ExecuteMenuItem("Edit/Play"); }
}
  
To enable this functionality, place this script into Editor folder and then press F5 to enter/exit Play Mode.
 
More Information
 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.