- Home /
Question by
Magok_Stelios · Mar 24, 2014 at 01:46 PM ·
issuedontdestroyonload
Issue with DontDestroyOnLoad
Hello there, I have an issue with DontDestroyOnLoad. I have in my first scene a GameObject called settingsContainer (obviously it holds some settings for the player). On second scene I have a script something like that:
void Awake()
{
instance = this;
DontDestroyOnLoad(GameObject.Find("settingsContainer"));
}
but later I can't access the game object because it doesn't exist... I can't see it either in my Hierarchy.... I'm sure I don't destroy it anywhere.. any idea what can be going wrong? something i should check about it to fix that?
Comment
Just make a dontdestroy script to place directly onto the object you're wanting to do that to.
void Awake()
{
DontDestroyOnLoad(this.gameObject) ;
}
http://docs.unity3d.com/Documentation/ScriptReference/Object.DontDestroyOnLoad.html
Your answer