Question by
ilusja · Mar 30, 2020 at 08:00 AM ·
unityeditorrestart
Restart Unity from script in Mac / Windows
Is there a way to restart Unity using a script? E.g. you wan't to restart Unity after the import of some packages. Is this possible?
Comment
Answer by ilusja · Jun 02, 2020 at 01:07 PM
I've found the solution:
var method = typeof(EditorApplication).GetMethod(
"CloseAndRelaunch",
BindingFlags.Static | BindingFlags.NonPublic);
string[] args = Environment.GetCommandLineArgs();
var methodParams = new object[] {args};
if (method != null) method.Invoke(null, methodParams);
else Log.Error("Can't restart Unity. Can’t find CloseAndRelaunch method in EditorApplication class.");
Your answer
