Currently when I want certain variables to be used throughout all of my scenes I tend to use DontDestroyOnLoad. However in case the original scene loads again I have two instances of the same object and if this continues many more. Is there another way that does not involve writing into an external file?
Hi ,
in that case don’t put the GO, that you don’t want to be destroyed, directly into a scene that will be loaded again.
You could either put it into a “starting scene” that you won’t load again or you could instantiate the GO with the help of a script at some place and check later on, if the GO already exits to avoid having doubles.
–
oxl
Thank you for the reply. I will give it a try, although the idea of using a file seems to be a good idea after all.