I have passed the gameobject(container) to other scene and made changes in it. Again when i load the previous scene which contain the gameobject it appears no changes have been done but when click on the mesh filter (where changes r done ie i have disabled the renderer ) on the hierarchy window shows two gameobject(container) in which one has the changes the other doesn’t
can u plz tell me why there r two gameobject(container) of the same name children
plz help
thanks in advance
If you’ve marked a scene object with DontDestroyOnLoad then it will be kept when you load in a new scene. However, if you go back to the first scene, the original scene object will be loaded in again. If you’ve got something like
function Start() {
DontDestroyOnLoad(this.gameObject);
}
…on a scene object, you will find that each new copy that gets made as the scene loads will be kept and you’ll just keep getting more and more of them. It’s best if you create these “immortal” objects using instantiation and check if one already exists before creating another:-
// Try to fInd the object by name
var dataObject: GameObject = GameObject.Find("DataObject");
// If it doesn't exist, then instantiate it
dataObject = Instantiate(Resources.Load("DataObjectPrefab"));