Best way to attatch text to text script c#
So I have a script that writes how much gold the player has, however when I load the scene (using a dontdestroyonload) I get an error because I simply made the text public and dragged in the UI element I wanted it to be. But when I reload the scene it doesn't know what element I dragged in and returns an error. What is the best way to fix this?
Comment
Which element is getting deleted with the scene loading? Are you dragging it in at runtime ?
Thanks for trying to help! So you know how a public variable shows up in the inspector? When I reload the scene it shows it being empty. Does that help?
Answer by upasnavig90 · Mar 02, 2018 at 11:01 AM
you can use GameObject.find("text") in start when it loads the scene.