添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I’m working on a tool that requires the editor to be restarted at some point. I can simply show a prompt to the user to do so, but ideally, I would then automatically close and reopen the editor. Is there a built-in API for this?

If not, what would be a clean way of achieving this? I’m thinking of calling EditorApplication.Exit , but not sure if I can restart the editor from within a call of the editor itself via e.g. Process.Start .

I then found the EditorApplication.OpenProject and passed in the path to the current project. However, although it closes the editor, it only opens the Hub, but not the project again. Is this maybe only an issue if trying to open the project that is currently open?

Don’t mind me, I was getting caught up in stupid path handling, but leaving this here as info for others:

[MenuItem("Tools/Reopen Project")]
public static void ReopenProject()
    string projectPath = Application.dataPath.Remove(
        Application.dataPath.Length - "/Assets".Length, "/Assets".Length);
    EditorApplication.OpenProject(projectPath);

Or a little shorter:

[MenuItem("Tools/Reopen Project")]
public static void ReopenProject()
    EditorApplication.OpenProject(Directory.GetCurrentDirectory());
 Xarbrough_1:

Don’t mind me, I was getting caught up in stupid path handling, but leaving this here as info for others:

[MenuItem("Tools/Reopen Project")]
public static void ReopenProject()
    string projectPath = Application.dataPath.Remove(
        Application.dataPath.Length - "/Assets".Length, "/Assets".Length);
    EditorApplication.OpenProject(projectPath);

Or a little shorter:

[MenuItem("Tools/Reopen Project")]
public static void ReopenProject()
    EditorApplication.OpenProject(Directory.GetCurrentDirectory());

Thank you , i was looking for this