- Home /
DontDestroyOnLoad vs Hideflags.DontSave
What's the difference between DontDestroyOnLoad vs Hideflags.DontSave. I have an audio system in form of a scriptable object. It has some functions like PlaySfx or PlayMusic that other objects can call. When the game first starts, the scriptable object will create a placeholding game object to hold an AudioSource component. So it's obvious that I want this game object to be persistent for the hold game. Should I use DontDestroyOnLoad or Hideflags.DontSave in this example? Another situation that I may have is my pooling system. I want to allocate many objects at the beginning of the game and need it to stay persistent across all scenes. What's should I use in this instance?
Answer by logicandchaos · Sep 10, 2021 at 03:51 PM
ScriptableObjects persist on their own, you don't need to use Don'tDestroyOnLoad or Hideflags.DontSave
If you read the question carefully, you would see that I said I create a placeholding "game object" that has an AudioSource component. And I want this game object to be persisted across all scenes.
Your answer
Follow this Question
Related Questions
Continuous AudioSource in DontDestroyOnLoad 1 Answer
DontDestroyOnLoad problem 1 Answer
Pooling Issue 0 Answers