I have a game object that's supposed to stay in every scene throughout the entire game. However, for some reason whenever I return to that scene there are duplicates of that object and it causes problems with the variables. The object retains variables throughout several scenes. Is there a way that I can destroy the other object of the same name when I reload a scene. Example: I go from the main menu to a level, then I go back to the menu and there is another instance of the object which causes problems with the variables.
Answer by hijinxbassist
Jun 18, 2012 at 05:06 AM
Its probly because each scene already has this object. Leave it in a starting 'buffer' scene only(scene you never return to after starting up the game. If you have the object in say, the main menu scene only, each time you return to that scene you will now have another instance of it.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
4 People are following this question.
How can i load may last scene without load duplicate?
DonDestroy dont save scripts
Save & Load Game question
Setting variable as type "Scene"
How to prevent objects instantiating between scenes?