Hello, I was wondering if it was possible to configure Unity Preferences (Unity → Preferences) from C#?
More specifically, I would like to enable cache server and set the IP address to use from a script that would run at startup so it doesn’t require the user to manually (aka remember) to do this.
The problem there is that the keys are not publicly available. I know that eg. auto-refresh is set through:
EditorPrefs.SetBool("kAutoRefresh", true|false);
Because @karl_jonestold me. Maybe he’s got some hot info on what cache server options and the IP adress are?
Of course, these values are written to the registry, so you could go hunting for a key in the registry that’s got the same value as the IP address you’ve set. I belive the EditorPrefs names and the registry keys are exactly the same. It’s probably under Unity somewhere?
Apparently there is an internal class in UnityEditor called CacheServerPreferences but Type.GetType(“UnityEditor.CacheServerPreferences”) failed to return a reference to it. There is a function in there called ReadPreferences() that loads values from EditorPrefs. It may not be necessary to call manually after setting the above anyway as my initial tests proved just setting the prefs using EditorPrefs did what I want.
It would be nice if there was a more official way of doing this, but I will take this over nothing.