- Home /
EditorPrefs.Set*() when using -batchmode -quit under MacOSX
Hi!
I have a EditorWindow implementation that I'm trying to save preferences for under MacOSX. In particular, I'm doing it from a command-line script that invokes Unity using -batchmode -quit
.
This is roughly what I have:
public class MyEditorTool : EditorWindow {
const string PREF_KEY = "MyEditorTool/MyStringPreference";
public static void SetPreferenceFromCommandLine() {
string[] args = Environment.GetCommandLineArgs ();
int argIndex = 1;
...
// (Scan for the appropriate command-line option index)
...
EditorPrefs.SetString (PREF_KEY, args[argIndex]);
}
...
}
So under MacOSX, I have a script that sets up the preference for a particular project that does the following:
/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode \
-executeMethod MyEditorTool.SetPreferenceFromCommandLine \
-projectPath <project_path> \
<my_preference_value>
Under MacOSX, this doesn't seem to work if -quit
is specified. However, without -quit
, it works if I close the Unity App.
Under Windows, the equivalent command line works with -quit
.
Am I missing something to commit the change to the preferences?
Thanks in advance.
Answer by aus_dw · Nov 27, 2015 at 10:06 AM
I managed to find a workaround by adding EditorApplication.Exit (0);
at the end of my SetPreferenceFromCommandLine()
method above.
It doesn't appear to cause problems with also having -quit
specified.
This worked for me also. Thank you for reporting back here after you found the solution.
Your answer
Follow this Question
Related Questions
Does EditorApplication.update get called in -batchmode when calling -executeMethod? 1 Answer
Changing tag not working in batchmode 0 Answers
Stop running script when object is selected. 1 Answer
quiting the game when triggered 1 Answer
How do I Force Application to Quit if no internet connection available 1 Answer