- Home /
Change Unity Project Settings through Script
Briefly: Is there a way to change various Unity Project Settings (Edit > Project Settings > ...) via C# code?
Detailed: I created an editor extension that adds a custom File menu suite of tools that we us across our company projects. One of these items is used to initialize a project so it meets our company standards. Currently, this sets up a default folder structure and sets up all .gitignore files. Everything works great so far.
However, I would also like to manipulate Edit > Project Settings > PlayerSettings to populate the Company Name setting. And more importantly, I would like to manipulate Edit > Project Settings > Editor to make the project ready for git. Any suggestions?
Answer by skylem · Jan 13, 2015 at 10:56 PM
heres the docs on referencing Player Settings
judging from the documentation it should be a rather simple process something like
compName = EditorGUILayout.TextField("Company Name:", compName);
or
UnityEditor.PlayerSettings.companyName = "someBS";
Edit to include ur next question ---
UnityEditor.EditorSettings.serializationMode = UnityEditor.SerializationMode.ForceText;
appears to be the correct way to do this, enjoy.
Edit to Include documentation --- turns out its EditorManager
Edit to include Setting ExternalVersion --
UnityEditor.EditorSettings.externalVersionControl = "Visible Meta Files";
Good call with the UnityEditor.PlayerSettings.companyName = "someBS"; That does allow me to change the company name properly. But I can't find a similar option for the Edit > Project Settings > Editor section. Specifically, I want to change Asset Serialization to "Force Text".
changed my answer to include this, hope thats everything u needed.
I don't know how I didn't find that earlier in my searching, but it's exactly what I wanted. Thanks for the great answer!
Actually, I can't seem to find the documentation on EditorSettings. I did find it in the jp docs, but it doesn't actually mention EditorSettings.serialization$$anonymous$$ode and I don't seem to find it in the US docs at all. Where did you find the documentation on UnityEditor.EditorSettings.serialization$$anonymous$$ode?
I was actually unable to find the documentation on EditorSettings, i worked it out by blindly experimenting with lines in C# until it gave me the values i was looking for ill have a look through the documentation and be back soon.
Your answer
Follow this Question
Related Questions
Is there a way to get all editable fields of a component in a script? 2 Answers
Run method of editor script when application is playing 1 Answer
Play Unity Editor from VSCode? 0 Answers
Dynamic content in custom EditorWindow 1 Answer
Can Unity Editor enter PlayMode without reloading a script 1 Answer