Getting player settings for a specific build profile

Hey there, working on a building script, and i wanted to get the player settings for a specific build profile. Is there any way to achieve this ? Didn’t find anything…

You can use buildProfile.GetComponent<PlayerSettings>().

Note that this will get you the global player settings if the build profile doesn’t override it.

hmmm … unfortunately everything is static in the PlayerSettings class so we can’t get anything out of an instance … or am i wrong ? each build profile have a serialized YAML version of the PlayerSettings class, but again, everything is internal to the BuildProfile class and can’t be read…

Ah, yeah, it’s a bit cumbersome but you need to use the SerializedObject and SerializedProperty APIs.

e.g.:

var so = new SerializedObject(playerSettingsObject);
var versionProp = so.FindProperty("bundleVersion");
versionProp.stringValue = "1.1.0";
so.ApplyModifiedProperties();

You’ll need to figure out the correct property names and types from the serialized YAML data or by using SerializedObject.GetIterator.