So I have 3 game objects that has dontdestroyonload script on it because those will be carried around upon scene change.
private Scene current_Scene;
private string[] onShowScene = new string[2] { "Startup", "Inside_House" };
public GameObject[] objectToDisable;
private int disableAmount;
void Start()
{
current_Scene = SceneManager.GetActiveScene();
disableAmount = onShowScene.Length + 1;
if (!controllerExists)
{
controllerExists = true;
DontDestroyOnLoad(transform.gameObject);
}
else
{
Destroy(gameObject);
}
}
void Update()
{
if (current_Scene.name != onShowScene[0] || current_Scene.name != onShowScene[1])
{
for (int i = 0; i < disableAmount; i++)
{
objectToDisable*.SetActive(false);*
}
}
else if (current_Scene.name == onShowScene[0] || current_Scene.name == onShowScene[1])
{
for (int i = 0; i < disableAmount; i++)
{
objectToDisable*.SetActive(true);*
}
}
}
}
here’s the script. This is attached to a game master object which will take an array of gameobject that i will be putting my camera, UI, and player. I want to disable these three game objects while on the main menu scene and as soon as I enter my next two scene, I want to reactivate the 3 objects. But after disabling these three objects the setactive(true) won’t activate it.
I suspect it is something about the game master will no longer hold the objects in its public gameobject once those are disabled, but then how I do want to disable those objects while on the main menu screen.