Hello!
I have two presets for Player Settings.
Now I want to change the Player Settings preset via Editor script.
I know I have the method of Preset.ApplyTo(Object o), but I don’t know how can I get the Instance Object of PlayerSettings in order to inject it into this method.
Someone knows how?
Thanks
Hi
I wrote this code:
var playerSettings = FindObjectOfType<PlayerSettings>(true);
var isSuccess=preset.ApplyTo(playerSettings);
AssetDatabase.RefreshSettings();
The preset.ApplyTo returns true, but the Player Settings does not change… any suggestions?
Hey! Did you figure this out? Im implementing something similar as well
Preset preset = AssetDatabase.LoadAssetAtPath<Preset>(presetPath);
var playerSettings = Resources.FindObjectsOfTypeAll<PlayerSettings>()[0];
if (preset != null)
{
bool success = preset.ApplyTo(playerSettings);
Debug.Log("Settings status: "+success);
//AssetDatabase.SaveAssets();
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(playerSettings));
}
else
{
Debug.LogError("Preset not found at path: " + presetPath);
}
tried this, no luck either
Preset preset = AssetDatabase.LoadAssetAtPath<Preset>(presetPath);
var playerSettings = Resources.FindObjectsOfTypeAll<PlayerSettings>()[0];
if (preset != null)
{
bool success = preset.ApplyTo(playerSettings);
Debug.Log("Settings status: "+success);
AssetDatabase.Refresh();
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(playerSettings));
}
else
{
Debug.LogError("Preset not found at path: " + presetPath);
}
This worked. Give it a try.
1 Like