x


BCE0019: 'cont' is not a memBCE0019: 'cont' is not a member of 'UnityEngine.Component'. ber of 'UnityEngine.Component'.

hi guys... I have a problem whit this exception at this line:

var trigger=GameObject.Find("Macchina"); var continua=trigger.GetComponent("GestioneTrigger").cont;

I have previously created the script "GestioneTrigger", and inside there is only a boolean variable. My goal is to take the boolean variable from another script but I have this exception.

more ▼

asked Jul 21 '12 at 11:25 AM

francedema gravatar image

francedema
1 2

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

1 answer: sort voted first

Try like this:

var trigger=GameObject.Find("Macchina"); 
var continua:GestioneTrigger =trigger.GetComponent(GestioneTrigger);

continua.cont;
more ▼

answered Jul 21 '12 at 11:27 AM

fafase gravatar image

fafase
10.5k 9 15 40

The simple/short answer is, don't use strings in GetComponent ;). That way the compiler can't determine the type that is returned by GetComponent. When using a type, the compiler will return the correct reference type (in your case a GestioneTrigger reference).

Jul 21 '12 at 11:47 AM Bunny83

thank you so much... now it's corret!

Jul 21 '12 at 12:07 PM francedema

thank you so much... it's ok!

Jul 21 '12 at 12:09 PM francedema

Please tick correct answers :)

Jul 21 '12 at 12:10 PM whydoidoit
(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:

x3325
x2083
x982
x839
x405

asked: Jul 21 '12 at 11:25 AM

Seen: 264 times

Last Updated: Jul 21 '12 at 12:10 PM