Quantcast
Channel: Latest Questions by t9s1n2
Viewing all articles
Browse latest Browse all 40

Using for ... var ... in loop to access variable.

$
0
0
I'm trying to draw the variable number that every cube has but it's not working. The cubes are instantiated and the variable is set in the cubes randomly. I tried drawing cube.transform position and that worked. I also tried cube.transform.number. I think i don't know how to access the variable correctly. function OnGUI() { cube = GameObject.FindGameObjectsWithTag("Cube"); for (var cube in cube) { var ray : Vector3 = camera.WorldToScreenPoint (cube.transform.position); GUI.Label (Rect(ray.x-16,ray.y+16,ray.x+16,ray.y+32), ""+cube.number); } }

Viewing all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>