So basically im creating a space sandbox game on mobile where you can create your own universe. At the start of the game you can choose your rocket. Every rocket has its own Camera, Player and Spawner attached to it. Not the nicest solution but it works. After the player chooses his rocket, I destroy the spawners on the inactives ones, so they dont work. My problem is when exiting the scene and choosing a different rocket and repeating the process, the SpawningManager with all the references to all Spawners lost the references to them. Even though I reloaded the scene all references are still lost. Sorry if this was hard to follow but it was hard to explain.
Here is a part of the code that destroys the spawners(represented by colors)
if (BlueSelected == true)
{
Destroy(RedSpawner);
Destroy(OrangeSpawner);
Destroy(YellowSpawner);
Destroy(GreenSpawner);
}
And a part of one of the planet spawner(represented by colors)
{ public Transform SpawnPointBlue, SpawnPointRed, SpawnPointOrange, SpawnPointYellow; public GameObject Mercury;
// Checks if the Spawner is greater than null (There or not) and Instantiates the Object at the Players Position
public void SpawnMercury()
{
if(SpawnPointBlue != null)
{
Instantiate(Mercury, SpawnPointBlue.position, SpawnPointBlue.rotation);
}
if(SpawnPointRed != null)
{
Instantiate(Mercury, SpawnPointRed.position, SpawnPointRed.rotation);
}
if(SpawnPointOrange != null)
{
Instantiate(Mercury, SpawnPointOrange.position, SpawnPointOrange.rotation);
}
if(SpawnPointYellow != null)
{
Instantiate(Mercury, SpawnPointYellow.position, SpawnPointYellow.rotation);
}