Hi I need to be able to set a gameObject as false in another scene, so even if I make the gameObject public I can’t assign the gameObject to the code in the inspector because the gameObject isn’t in the current scene.
After searching for an answer for this, I’m led to believe it can’t be done because the gameObject doesn’t exist until the new scene is loaded.
It would just solve so many problems if there’s a way to do it. The gameObject is being used to hold code that saves the positions of other gameObjects in the scene, and I want to be be able to disable the gameObject when a new game is started, and thus resetting gameObjects to their original positions.
public static GameObject gameObjectInOtherScene;
public void loadScene(int LoadScene)
{
SceneManager.LoadScene("Scene_1");
gameObjectInOtherScene.SetActive(false);
}
No, I don’t think there’s a way at runtime to access GameObjects in scenes that don’t exist. You’ll have to do something else, like setting a “NewGame” flag in the GO you want to access and using that to determine what data it contains. Honestly though, your setup just feels weird in general and there’s probably a more logical way to go about it if you could explain the problem further.
Thanks for the feedback. And yes, it’s weird. I’m trying to create a game in Unity that I’ve written on paper that has 768 scenes. I was thinking of trying to create 768 scenes in the scene manager, but I thought 50 scenes with 16 environments each might work but it’s proving hard (after saving those environments locations) to have the option to reset the locations if you choose to create a new game. If I can only deactivate the gameobject in the scene that is holding the information through the plugin EZY Save, the objects do go back to their original positions. I think it could work but right now I’m confusing myself.