Saturday, 29 July 2023

Variables between scripts

 If we want to access one variable (int data) from an external script, we must do:

1-ORIGINAL ONE.cs


   public static int data=0

2- SECOND TWO.cs

 

ONE.dinero = 1;

As u can see, the only secret its to declare "public static" your variable.

Of course, your 2 scripts must be on the same scene assigned to a GameObject.



Variables between scripts

 If we want to access one variable (int data) from an external script, we must do: 1-ORIGINAL ONE.cs     public static int data = 0 ;  2-...