Enabling/disabling a component.

Hi, i am working on iPhone game and i have to enable/disable the components. i am using this but when i click the build button it gives me error.

GetComponent("NetworkRigidbody").enabled = false;

and this is the error i get.

Error building Player because scripts had compiler errors

its working for webplayer but not for the iphone.

thanks in advance for any help.


I hope , the solution of your problem should be…

GetComponent < T >().enabled = false;

where T  will be component's name which is attached of this game object. Like :

GetComponent < NetworkRigidbody >().enabled = false; < T >



I guess the plblem of sample below.

I moved NetworkRigidbody to “Plugins” folder I created.
And, I fix it like this

(GetComponent("NetworkRigidbody") as NetworkRigidbody).enabled = false;