- Home /
Question on Singleton Object / Hierarchy Relationship
Hello everyone, recently I've needed to carry some data over from one scene to another and so forth. So I made the script in question into a singleton as usual, but there seems to be a catch, because the GameObject that is now a singleton is not the parent object, when the new scene loads the singleton is still destroyed.
The setup:
Singleton Script Element:
void Awake()
{
if(generic_Singleton == null)
{
generic_Singleton = this;
DontDestroyOnLoad(this.gameObject);
}
else
{
Destroy (this.gameObject);
}
}
Hierarchy Setup:
Parent
-Child
-Child (that has a script making it a singleton, will still be deleted on Load)
I've checked the singleton script and it does work (provided the GO is a parent). I really don't want the Parent object to transfer over, so is there a new/better way of doing that? (I should also note that these objects involve NGUI, so un-parenting the GO is not possible)
Any ideas are appreciated.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
A node in a childnode? 1 Answer
Multiple Cars not working 1 Answer
Scale fit? 1 Answer