Hello its me again with my annoying questions
So i understand the logic behind the singleton
void Awake()
{
SetUpSingleton();
}
private void SetUpSingleton()
{
if (FindObjectsOfType(GetType()).Length > 1)
{
Destroy(gameObject);
}
else
{
DontDestroyOnLoad(gameObject);
}
}
So step by step
- (FindObjectsOfType(GetType()).Length > 1) we want to see how many scripts we can find type .
Lets say we are on scene 0 at the moment and we have 1 MusicPlayer type.
Now when we want to load scene 1 how can the program count 2 MusiPlayer type?
in my logic we are on scene 0 with 1 MusicPlayer type if we load Scene 1 then Scene 0 is deleted.
The only logical way is for me is that Unity is Loading scene 1 and after is loaded then deletes scene 0 so
the SetUpSingleton(); can run?
Sorry if i give you headache Nina