Access to the variable which is other script and object (C#)

Hi! :slight_smile:
For example some variable is declared in script “Script1” and i wanna refer to it in script “Script2”. How can i do this?

There are several ways. The easiest is to make a public Script1 variable in Script2:

public Script1 targetScript1;

and then in the editor, drag the Script1 that you want to access onto the new field in Script2. Then, as long as the variable in script1 is public you can just do targetScript1.whatever.

I suggest you go and do some tutorials.

The lerpz one is a great introduction to all these basic unity concepts.

I believe you can find it in the asset store