I have a case of 2 scenes :
A - is a loadscreen where i proposed a number of buttons corresponding to different levels of the game
B - are a certain level of the game
A is generating the buttons by the code:
for (int i = 0; i < LevelNumber.nbLevels; i++) { GameObject newButton = Instantiate(levelButtonPrefab); newButton.GetComponent<LevelButton>().SetButton((i + 1).ToString(), "LevelG"); //connexion à LevelG newButton.transform.SetParent(grid, false); //The new created button is part of our grid
}
levelButtonPrefab is a prefab object.
The activation and connexion to LevelG works well, but when i come back to scene A,game object newButton are destroyed.
How can i proceed to conserve newButton game object as i don't have newButton in Inspector ?
Thanks in advance,