Answer the question
In order to leave comments, you need to log in
How to use a variable from another script?
It's simple, there are two scripts. One of them contains a variable that I want to use in the other.
How can I access a variable from another script?
thank you*
Answer the question
In order to leave comments, you need to log in
If I'm not mistaken, create an object of the class (script) and use it to access the variable.
As usual, we need a reference to the desired class instance (well, unless of course it's a static variable).
Or we drag this link in the inspector in advance. Or we look for the GameObject we need in any possible way and get the component we are interested in from it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question