I am attempting to turn off all of the child objects SkinnedMeshRenderers and I am using his script:
var theObject : GameObject;
function Update ()
{
theObject.GetComponentsInChildren.<SkinnedMeshRenderer>().enabled = false;
}
However I am receiving this error on run-time:
MissingFieldException: UnityEngine.SkinnedMeshRenderer[].enabled
Would I have to call the individual renderers, or is enabled not used for renderers?
Cherno
2
Yes, you have to iterate through all the components and set each one’s active state seperately. You can’t use .enabled (or similar variables) with an array of objects.