Q
Q
Qerriom Magnelius2022-04-21 17:54:18
C++ / C#
Qerriom Magnelius, 2022-04-21 17:54:18

How to exchange variables between scripts in Unity C#?

Hey! Yes, a rather stupid question, but I searched the entire Internet ...
True, I did not find anything.
What do we have?
We have the first code attached to the button (a separate object in the canvas)
And the second, which, as planned, should take the value of a certain variable and move the object.
In theory, in the first one, on pressing, the value 1 will be assigned to a certain variable, and the second code will check the value of this variable.

And so, the question is:

How to exchange variables between scripts in Unity C#?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alalal24, 2022-04-21
@MicroProger

add to static variable at initialization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question