Quantcast
Channel: Answers for "How to correctly use GetComponentInChildren"
Viewing all articles
Browse latest Browse all 4

Answer by Kergal

$
0
0
I would change a couple of things. (but i use C#) . At the moment your your Array is of type component - which is weird (at least to me) . make it Transforms or GameObjects. then in your foreach loop. what do you want ? - you want to go through all the elements( that are now specified as GameObjects or Transforms ) of ourRenderer and turn them off. so I would go with foreach (GameObject temp in ourRenderer) { temp.renderer.enabled = false; } // (or SetActive(false) or something like that) however , I have not tested my approach and would -just for preference reasons use a regular for loop.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images