x


Accessing Class Vars?

Hello,

I'm trying to access a variable inside a class, but I'm having problems:

class JetPackSettings{
   var jetPackModel : GameObject;
   var jetPackOn : boolean = false;
}

var jetSettings : JetPackSettings;

function Awake(){
   jetSettings.jetPackModel.gameObject.SetActiveRecursivelt(false);
}

The 'jetPackModek' won't 'turn off'. What am I doing wrong here?

Thanks

more ▼

asked Sep 08 '11 at 12:07 AM

oliver-jones gravatar image

oliver-jones
2.5k 205 225 254

I don't code in javascript usually, but if its access policy is anything like C#, then the access modyfier is private by default, that is, when you write "var jetPackModel", the compiler assumes you mean "private var jetPackModel". You can't access a private class member outside the class. Add "public" in front of it and see if that helps.

Sep 08 '11 at 12:01 PM CHPedersen
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

public var jetPackModel : GameObject;

more ▼

answered Sep 08 '11 at 12:10 PM

Yasantha gravatar image

Yasantha
101 1 1 4

(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:

x337
x109
x31

asked: Sep 08 '11 at 12:07 AM

Seen: 355 times

Last Updated: Sep 08 '11 at 12:10 PM