Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Open "Build Settings" window via Editor script?

Discussion in 'Scripting' started by CrowbarSka, Apr 29, 2020.

  1. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Hello!

    Is it possible to pop open the Build Settings editor window via editor script?

    I have a button in my own custom editor window, and I want it to open the Build Settings window when clicked.

    Thanks in advance!
     
  2. SplenShepard

    SplenShepard

    Joined:
    Aug 24, 2019
    Posts:
    19
    Bump. Curious about this.
     
    CrowbarSka likes this.
  3. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    I did actually find a solution at some point, but forgot to update this thread. Sorry!

    Code (CSharp):
    1. using UnityEditor;
    2.  
    3. // Open BuildSettings as a dockable window
    4. EditorWindow.GetWindow(System.Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor"));
    5.  
    6. // Or, in older versions of Unity you can open it as the normal (non-dockable) floating window. Newer versions ALWAYS use a dockable window. I'm not sure when that changed.
    7. EditorApplication.ExecuteMenuItem("File/Build Settings...");
    Hope that helps. I personally just use the first solution listed above since I prefer dockable windows.
     
    MousePods, NMJ_GD, Rand_D and 2 others like this.