Quantcast
Viewing latest article 1
Browse Latest Browse All 40

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

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 latest article 1
Browse Latest Browse All 40

Trending Articles



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