-
-
Save nkjzm/418b5db0296570f79211fe28c5bd4002 to your computer and use it in GitHub Desktop.
UnityエディタでStopしたときにエディタを再起動するエディタ拡張です
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Unity Restart Editor On Stop | |
// @sh_akira | |
// Put this file to Assets/Editor/ | |
// | |
using UnityEngine; | |
using UnityEditor; | |
[InitializeOnLoad] | |
public static class RestartOnStop | |
{ | |
static RestartOnStop() | |
{ | |
EditorApplication.playModeStateChanged += EditorApplication_playModeStateChanged; | |
} | |
private static void EditorApplication_playModeStateChanged(PlayModeStateChange state) | |
{ | |
if (state == PlayModeStateChange.EnteredEditMode) | |
{ | |
RestartEditor(); | |
} | |
} | |
private static void RestartEditor() | |
{ | |
var unityPath = EditorApplication.applicationPath; | |
var args = "-projectPath " + "\"" + Application.dataPath.Replace("/Assets", "") + "\""; | |
System.Diagnostics.Process.Start(unityPath, args); | |
EditorApplication.Exit(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment