0

I'm beginner in Unity and trying to create a guessing number game. In first scene, I have 2 input fields and player will write lower and upper limit. I'll keep that variables as "inputmin" and "inputmax" in a script. In second scene, I want my game use those 2 variables as lower and upper limit. Tried to use "DontDestroyOnLoad" method, in game it passes the variables as dontdestroy object but I don't know how to use them in second scene's script. A little confusing text i wrote i guess i hope someone can help :)

1 Answers1

0

For an object that has DontDestroyOnLoad, get your script via yourobject.GetComponent<MinMaxScript>() And you will be able to get data from your script.

Or you can use Singleton, or save and load data from a file.

Yagir
  • 1
  • 1
  • Thanks, should I add any library for that method? Because i tried it but it didn't work. I mean, in first scene, i put my script which one is holding values in an object named "Limiter". In second scene's script, I wrote "Limiter.GetComponent();" but didn't work. GetInput is the first scene's value holder script's name. – tunahanarik Feb 20 '23 at 17:36