Question by
Tespy · Oct 27, 2020 at 10:28 PM ·
c#editorscriptableobjectplaymode
Code executing in play mode when it shouldn't
I have some initialization code I want some of my ScriptableObjects to execute ONLY when Play Mode isn't running. I have this in OnEnable:
#if UNITY_EDITOR
if (!Application.isPlaying)
{
Contents.Clear();
AddNonNullStartingContents();
}
#endif
In Play Mode, sometimes Contents.Clear (and strangely, not AddNonNullStartingContents) gets called, messing up the state of my ScriptableObject. Is this a bug, or did I just not set this up correctly?
Comment
Your answer
Follow this Question
Related Questions
Weird error appearing after playing in editor? 0 Answers
How to show and remove text before player has started the game? 1 Answer
Assign multiple Camera values to a single Scriptable Object 1 Answer
Load JSON Scriptable Object and Prefabs 1 Answer
How to make an attack that moves the players position relative the target. 1 Answer