- Home /
is there any way to keep first gameobject that has dontdestroyonload script and used as a variable?
hi i have a gameobject as ad manager that get a banner ad from server, the problem is that the server just send to me once per every games run, and if i reload scene i cant show banner, so add dontdesroyonload and singleton to my script, but in scene reload if keep previous gameobject because i use it as a variable in another script i get the missing error in scene reload, an if destroy previous its as like as didnt use dontdesroyonload . is there is any way to solve it?
Answer by MenimalsEntertainment · Apr 13, 2021 at 09:51 PM
@mohammad1369 I would try assigning it as a static variable to a script that persists throughout the scenes. If you have multiple game objects you could try using a static list of some sort. If your script references the static variable, it shouldn't change when you reload the scene.