- Home /
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
UnityEditor.HostView:OnGUI()
its working for webplayer but not for the iphone.
thanks in advance for any help.
It looks like you have a problem in your OnGUI function but I can't tell without your script.
Answer by Laksh · Aug 04, 2011 at 06:50 PM
Hi
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 >
Regards
Laksh
NetworkRigidbody is a C# script and i am trying to disable it with Javascript code. it works fine when i click play button of unity. but when i try to build For iphone it gives me error. which i have mentioned above in my question.
Answer by shinriyo_twitter · Sep 29, 2011 at 05:38 AM
Hi. I guess the plblem of sample below. http://unity3d.com/support/resources/example-projects/networking-example.html
I moved NetworkRigidbody to "Plugins" folder I created. And, I fix it like this [CODE] (GetComponent("NetworkRigidbody") as NetworkRigidbody).enabled = false; [/CODE]
Your answer
![](https://koobas.hobune.stream/wayback/20220612170016im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Animation does not start 1 Answer
How can I access a component in a parent object? 1 Answer
Adding joints through script 2 Answers