- Home /
How to open Player Settings with an Editor Script?
Is there any way to open player settings inspector (like the player settings button in the build settings); or to at least get the UnityEngine.Object for the player settings so that I can set Selection.objects to it?
Answer by Altaf-Navalur · Sep 17, 2013 at 11:34 AM
Hi, Try this, EditorApplication.ExecuteMenuItem("Edit/Project Settings/Player");
Thanks, Altaf
This is great, but do you know if there's a way to also open a specific platform tab? Apparently it will open the last opened one, but sometimes it forgets what that was (or you're opening a freshly checked out repo), and it just opens standalone. I've many times mistakenly set Scripting Define symbols, made rebuilds, wondered for ages why the defines didn't work, and then realised that I set them in standalone ins$$anonymous$$d of the platform I was on at the time...
Any time the library is rebuilt, you will lose that info, but Unity now has a new launcher app called 'Unity Hub' that allows you to specifically select which platform you want to open Unity in.
You can find the preview build on Unity's download page: https://unity3d.com/get-unity/download
This is indeed handy for deciding which build target to open a project with, however, my question in this case is about specifying which platform to open the player settings for. This doesn't default to the one that the build target is set to, though that would make sense, but ins$$anonymous$$d to Standalone (or at least it did back when I wrote that question)...
Answer by Chris-KillerSnails · Feb 13, 2019 at 04:41 PM
In Unity 2018.3 you should be able to do:
SettingsService.OpenProjectSettings("Project/Player");
This works if you want to open the Player Settings Window in the "New Unity Style", but if you want to open the player settings in the inspector, like the OP requested, you can still do this by using the method in @StephenHodgson-Valorem's answer :)
Using the "Unsupported" method that opens the Player Settings in the inspector has issues. One portable console target platform just sits there throwing exceptions when Player Settings is opened in the inspector this way. It doesn't do this when opened the new way through the Project Settings panel. This is the best answer.
Answer by StephenHodgson-Valorem · Dec 21, 2018 at 06:20 PM
FYI this no longer works in 2018.3+
You'll need to use:
Selection.activeObject = Unsupported.GetSerializedAssetInterfaceSingleton("PlayerSettings");
This does indeed work. However, "Unsupported" sounds like maybe it's not something we can expect will continue working? (I guess neither did the old one, so nothing lost I guess)
While this does work, there seem to be new issues when opening the Player Settings for some platforms in the inspector. For example, a portable console target platform sits there throwing exceptions when opened in the inspector using this method. It doesn't do this when opened the new way through the Project Settings panel. @Chris-$$anonymous$$illerSnails answer is better: It opens the new plane and it doesn't use a class called "Unsupported."
Answer by Graham-Dunnett · Jul 02, 2013 at 08:24 PM
Yes, that is how to access the PlayerSettings class members via script, but I am looking for how to open the player settings inspector UI via script.
Your answer
Follow this Question
Related Questions
Scripting Runtime Version Option not Appearing in Player Settings 0 Answers
Set the Inspector target in Playmode. 1 Answer
What are "template custom keys" in the Player settings? 0 Answers
Unity lag on selection 0 Answers
Active Inspector Object 1 Answer