Or has this been announced? I was making some changes to my code and forgot to Stop/Play and the code changes did work after saving the file without restarting the scene. It was a very simple change but still… pretty cool.
I wonder if this is work in progress and still not fully supported hence it hasn’t been officially announced.
I would really, really love to be able to deactivate this feature. I’ve never seen it work for anything larger than a game jam size project, and on our very large thing, it has a tendency to crash the editor.
It’s not quite enough on it’s own, as setting the autorefresh to true again when exiting play mode doesn’t trigger a refresh if any files are changed. So I’m calling AssetDatabase.Refresh(); as I leave play mode. That seems to have done the trick.
Relevant parts of my editor script if somebody’s interested:
[InitializeOnLoad]
public static class OnSceneLoadScript {
static OnSceneLoadScript() {
EditorApplication.playmodeStateChanged += ChangePlaymodeCallback;
}
private static void ChangePlaymodeCallback() {
//This is only kicks off when you have exited play mode.
if (!EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) {
EditorPrefs.SetBool("kAutoRefresh", true);
AssetDatabase.Refresh();
}
//Called just after play mode is entered
if (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying) {
EditorPrefs.SetBool("kAutoRefresh", false);
}
}
}
Edit one and a half year later, as I keep linking people to this. Originally the second if there looked like this:
//Called before play mode entered
if (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying)
If you changed a script in a way that introduced compiler errors, and then pressed “play” before the code was finished recompiling, the auto refresh would now be set to false, and you’d have to open the preferences menu to turn it back on. That was annoying, so turning auto refresh off after the game had entered play mode prevents that problem.
@karl_jones , a coworker just walked by and went “oh, that’s neat. Where’s the reference for all of the magical strings that does something in EditorPrefs?”
Is there such a reference other than looking at the registry?