Skip to content

Commit dc59563

Browse files
authored
Create EditorShortCutKeys.cs
1 parent ad72ed5 commit dc59563

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Scripts/Editor/EditorShortCutKeys.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using UnityEditor.SceneManagement;
4+
using UnityEngine.SceneManagement;
5+
6+
// original source by "Mavina" http://answers.unity3d.com/answers/1204307/view.html
7+
// usage: Place this script into Editor/ folder, then you can press F5 to enter/exit Play Mode
8+
9+
public class EditorShortCutKeys : ScriptableObject
10+
{
11+
[MenuItem("Edit/Run _F5")] // shortcut key F5 to Play (and exit playmode also)
12+
static void PlayGame()
13+
{
14+
if (!Application.isPlaying)
15+
{
16+
EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), "", false); // optional: save before run
17+
}
18+
EditorApplication.ExecuteMenuItem("Edit/Play");
19+
}
20+
}

0 commit comments

Comments
 (0)