S
S
Shameless192019-11-15 23:36:56
Unity
Shameless19, 2019-11-15 23:36:56

What needs to be written so that the script has access to variables from other scripts?

Good day
There are two scripts, the first one contains a variable, the second one should execute the if loop with the variable from the first script. However, he considers it non-existent.
What needs to be written so that the script has access to variables from other scripts?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2019-11-15
@Shameless19

If there is already a link to the script instance, then make the variable public (Public). Well, or write a getter.
If there is no instance, get it. There are a lot of options here - DI, creating one from the other, SerializeField, etc.
Read Sharpe books. It will be tough without him.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question