Skip to content

Instantly share code, notes, and snippets.

@sh-akira
Last active September 11, 2018 07:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sh-akira/bb4fc283ff4e0a8d5297ee12c22ba866 to your computer and use it in GitHub Desktop.
Save sh-akira/bb4fc283ff4e0a8d5297ee12c22ba866 to your computer and use it in GitHub Desktop.
UnityエディタでStopしたときにエディタを再起動するエディタ拡張です
//
// 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