By ayanez
on Thu, 07/10/2014 - 01:13
I am able to get the object information in the Update function and I'm able to see the Vector3 using Debug.Log()..but I cannot get this updated information in the OnGUI() function is there a way to make the Vector3 into a global variable so I can access it in the OnGUI() function? Here is my code:
using UnityEngine; using System.Collections; public class text : MonoBehaviour { public SimpleCloudHandler other; public Transform target; public static Vector3 screenPos; void Start(){ } void Update () { Vector3 screenPos = camera.WorldToScreenPoint (target.position); Debug.Log(screenPos[0]); } void OnGUI() { GUI.Label (new Rect(screenPos[0],screenPos[1],screenPos[2],50), "" + other.TextFunc()); Debug.Log(screenPos[0]); } }
Im trying to make the Label follow a tracker that will be overlayed onto my target
Thanks!