- Home /
enabled is not a member of 'UnityEngine.Component
I have this script:
function Update(){
if (Input.touchCount > 2) { GetComponent("look at object").enabled = true; } }
It works great in unity window, but when i build i get this error BCE0019: ('enabled' is not a member of 'UnityEngine.Component'.). Why does this happen and how can i fix it?
Answer by Jessy · Jan 28, 2011 at 03:46 AM
Don't use quotation marks. "look at object" is not the name of a class; a class can't have spaces in its name. Figure out what it is, and then use the generic form of GetComponent, which will return whatever type the component is, and not a Component.
function Update(){
if (Input.touchCount > 2) {
GetComponent.<TheRealNameOfYourClass>().enabled = true;
}
}
If you use JavaScript, the name of your class is the name of your script. I tested the code; it doesn't produce that error.
I assume you'll want to rename your script/class LookAtObject, by the way.
Answer by machomateo · Mar 13, 2013 at 10:50 PM
I have to same problem for
GameObject.Find("car").GetComponent("enter and exit car").Enabled=true;
this is not an answer
the question has already been correctly answered; read the answer
enabled starts with a lowercase letter
Answer by eweeparker · Apr 27, 2015 at 11:13 AM
var blah = myCamera.GetComponent.(); blah.enabled = false;
Your answer
![](https://koobas.hobune.stream/wayback/20220613101502im_/https://answers.unity.com/themes/thub/images/avi.jpg)