- Home /
GetComponentInChildren question
i have one cube & 6 children attach to Cube Game object & one of these children have "Swing" script attach i want to disable that but there is error coming
i using this script attach to the cube game object
if (Input.GetButtonDown("Inflated") && (currentform != 2))
{
GetComponent("NFmovement").enabled = false;
GetComponentInChildren("RopeLogic").enabled=false;
normalform.gameObject.SetActiveRecursively(false);
inflatedform.gameObject.SetActiveRecursively(true);
GetComponent("IFmovement").enabled = true;
currentform = 2;
}
}
& the error is : No appropriate version of 'UnityEngine.Component.GetComponentInChildren' for the argument list '(String)' was found.
Answer by Jessy · Apr 07, 2010 at 05:24 AM
As you can see in the documentation, you can't use strings as arguments with GetComponentInChildren, the way you can with GetComponent. So just leave off the quotation marks. Even with GetComponent, you should leave them off for better performance.
i already try this but still above error co$$anonymous$$g & another error co$$anonymous$$g that $$anonymous$$ identifier: 'RopeLogic'.
Are you mixing JavaScript and C#? I don't recommend it, but I don't see why you'd get that error otherwise. Here's information on how to deal with that:
i figure out how to do that by the way thanks for helping me
Your answer
Follow this Question
Related Questions
How to correctly use GetComponentInChildren 2 Answers
Text Not Being Displayed above Instantiated Prefabs 0 Answers
instantiate an prefab and get its child's script 1 Answer
how do I change the properties of a material that are on the children of an object on script? 1 Answer
GetComponent in parent question 3 Answers