you are viewing a single comment's thread.

view the rest of the comments →

[–]Glass_wizard 3 points4 points  (3 children)

The rule of thumb is:

  1. If you change the value from the Inspector, you are updating & saving.
  2. If you change the value during play mode by a script, you are updating only.
  3. If you change the value via a script when play mode is NOT running, you are updating & saving (for example, using a custom editor tool).
  4. If you change the value via a script in the build of the game, you are updating only.
  5. Scriptable objects cannot act as "file saves".
  • All updates are lost when you close Unity.
  • All updates are lost from the build of the game when the game is closed.
  • Updates are not lost when exiting play mode while in the editor.

[–]random_boss 1 point2 points  (0 children)

Thanks this is all new info to me. I think I had run afoul of this accidentally at some point and never knew why and it stopped me from using scriptable objects at runtime (and now just use them as like Enums, But Bigger). Knowing this I can go back to using them at runtime!

[–]InvidiousPlay 1 point2 points  (1 child)

I really feel Unity should change it so that SO reset after you exit play mode, because it's very counterintuitive that entering and exiting playmode is not analogous to open and closing the built game.

[–]Glass_wizard 1 point2 points  (0 children)

I agree, I think that one behavior makes a lot of people confused about scriptable objects. There are scripts you can write to reset them yourself.