LoginSignup
0
0

More than 5 years have passed since last update.

Unity: Pass a value between scenes

Posted at

static modifier

As long as your script has a derived class of Monobehaviour and has a static variable in it and add the script to some component in a scene, you can share the value between scenes.

I thought it would be better to show the visual aid.
static modifier explanation.png

As seen in the image, the "Score.cs" has a variable "score", which is 0. The value could be shared between scenes. Obviously there are other ways to do the same thing, but I just thought my way is easy, and understandable for beginners just like me.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0