Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.