- Home /
Question by
Wezinator35 · Apr 16, 2015 at 01:51 AM ·
.ma
Global Variables
I need help making a variable that connects to other scripts. I tried this: static var uploads : int; function Awake(){ uploads = 0;
Comment
While a public static variable is global, in most cases this is not the best way to connect scripts. Have a look at GetComponent ins$$anonymous$$d.
Answer by furic · Apr 16, 2015 at 02:12 AM
you need to make it public, for example:
MyScript1.cs:
public static int myValue = 1;
access from other scripts such as in MyScript2.cs:
MyScript1.myValue = 2;
Your answer
![](https://koobas.hobune.stream/wayback/20220613193234im_/https://answers.unity.com/themes/thub/images/avi.jpg)