x


How to make a global variable in Unity?

im trying to make a global variable so other scripts can do stuff with it. How do i make a variable global?

edit using java

more ▼

asked Mar 05 '11 at 05:17 PM

NathanDaniels gravatar image

NathanDaniels
44 2 2 9

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I'm pretty sure this has already been answered but you can always put

static var

infront of something and that makes it accesible from other scripts.

more ▼

answered Mar 05 '11 at 05:20 PM

AngryOldMan gravatar image

AngryOldMan
2.6k 12 21 47

So simple but thank you!

Sep 26 '12 at 08:28 AM Nercoe
(comments are locked)
10|3000 characters needed characters left

You can use the "static" modifier. In C#, that would be

public static int myInt = 0;
more ▼

answered Mar 05 '11 at 05:20 PM

jashan gravatar image

jashan
10.3k 25 43 117

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x848
x127

asked: Mar 05 '11 at 05:17 PM

Seen: 5184 times

Last Updated: Sep 26 '12 at 08:28 AM