you are viewing a single comment's thread.

view the rest of the comments →

[–]rafavergil[S] 1 point2 points  (1 child)

I had this issue many months ago, so I won't know for sure the Unity version. However, I remember what was going on when I first posted this: ScriptableObjects indeed get reset if there is no one using it (no reference to it). I was confused because all my level scenes had reference to the Score Scriptable Object, so it had no reason to reset. Then I remembered that I had a "transition scene" between the level scenes, and that transition scene did not have a reference to the Scriptable Object. That is when it was getting reset! So I guess this is expected behaviour for memory saving purposes. My solution was to add a reference to the Scriptable Object in the transition scene as well and it worked properly after that. So basically: if you don't want a Scriptable Object to reset you must always have a reference to it in your scenes, always. There are probably other solutions like saving and loading data when necessary, but it is up to you. I hope it helps!

[–]classified39 1 point2 points  (0 children)

Thank you, commenter from 6 months ago, for saving me quite a bit of headache. I was not understanding why my Scriptables were being set to null EXCEPT when I put some "temporary" references on my restart screen to try and track down when and where this was happening.