- Home /
BCE0019: 'GetComponentsInChildren' is not a member of 'Object'.
This if for WehicleScript.js error at both 'Player.GetComponentsInChildren' what should I write to fix it?
function GetOut() {
// Enable all script behaviours on Player (Essentially deactivating player control)
var coms : Component[] = Player.GetComponentsInChildren.<MonoBehaviour>();
for (var b in coms) {
var p : MonoBehaviour = b as MonoBehaviour;
if (p)
p.enabled = true;
}
// Enable all renderers
var gos = Player.GetComponentsInChildren.<Renderer>();
for( var go : Renderer in gos){
go.enabled = true;
}
Answer by sirival · Nov 25, 2012 at 05:09 PM
What type is the Player variable? If it is of type Object then you cannot call GetComponentsInChildren as this function is declared in the Component class ( http://docs.unity3d.com/Documentation/ScriptReference/Component.GetComponentInChildren.html )
Player is not type of object meanwhile below is the original script that worked fine though after import the problem occur even I have alter the script as above
var coms : Component[] = Player.GetComponentsInChildren($$anonymous$$onoBehaviour); for (var b in coms) { var p : $$anonymous$$onoBehaviour = b as $$anonymous$$onoBehaviour; if (p) p.enabled = true; } // Enable all renderers var gos = Player.GetComponentsInChildren(Renderer); for( var go : Renderer in gos){ go.enabled = true; }
Your answer
Follow this Question
Related Questions
error for array functions 2 Answers
finish line script 3 Answers
transform.position not a member??? 2 Answers
dynamic typing in Unity iOS: ...not a member of 'UnityEngine.Component' 2 Answers