Can't drag variables between different scenes
Hi, I'm having an issue with SceneManager.LoadSceneAsync(scene, LoadSceneMode.Additive)
I have a "Player Scene" which contains my Player, along with any managers for score, inventory ect. But, when a new scene gets loaded additively, all references to the Player are missing, and I cannot drag the references from the Player because it is in it's own separate scene.
Originally, I had a clone of the Player in each separate scene, and I could just assign the variables from that Player, but now I want the Player to be persistent between scenes, so I removed the Player from all scenes besides the "Player Scene", but now all other scenes have "Missing reference exceptions". What is the solution to this?
Any help is greatly appreciated! thanks.
Answer by Cuttlas-U · Sep 25, 2017 at 05:44 PM
hi; if u want an object not to be deleted u should attach a script to it and put this lane of code in it :
void Awake () {
DontDestroyOnLoad (transform.gameObject);
}
the object that this script is attached to wont be destroyed during scene changing ;
so i think u need to atttach this script to all the player refrence objects like manager and etc ... this way all of them will stay to the next scene ;