- Home /
 
GetComponentInChildren is not a member of 'Object'
I'm having a problem with GetComponentInChildren. I get an error saying : BCE0019: 'GetComponentInChildren' is not a member of 'Object'.
This is my code:
 function SetRandomNumbers ()
 {
     for(var child in transform)
     {
         var weight : int;
         weight = Random.Range(0,10);
         child.GetComponentInChildren(TextMesh).text = weight.ToString(); 
     }
 }
 
               Thanks for your help!
               Comment
              
 
               
              Answer by robertbu · Jul 23, 2014 at 01:38 AM
Declare the type of 'child':
  for (var child : Transform in transform)
 
               Without a type, the compiler defaults to Object.
Thank you so much I've been trying to figure that out for hours!
Your answer
 
             Follow this Question
Related Questions
Random time interval 1 Answer
How can I match and display two random numbers using C#? 2 Answers
GUI Problem 2 Answers
Random.Range affects the Random.seed 1 Answer
A problem with relative velocity 1 Answer