- Home /
Displaying GUI.box in VR Headset in Scene
Hello,
I currently have two GUI.boxes that are displayed on screen in Unity. I am able to switch text how I planned to, but cannot see anything in my VR Headset (HTC Vive with asset stores SteamVR plugin). I want the two boxes to stay in the top left corner of the camera\s view as it moves around. I think there is some way to do it by making game objects and attaching boxes to it and then using WorldtoScreenpoint, but I would have to assume there is something I can do that doesn't involve that. Is it possible for me to get the screen point coordinates (should be 10,40 from the top left) and convert it to viewport for the camera? I have tried something similar to no avail so I may be using ScreentoViewPort wrong.
Would using some UI component be better than a GUI box for this?
using UnityEngine;
using System.Collections; using UnityEngine.UI; public class RotationText : MonoBehaviour{
HeadRotation headrotation;
public uint mood1;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void FixedUpdate ()
{
headrotation = GetComponent<HeadRotation>();
mood1 = headrotation.mood;
//Debug.Log (mood1);
}
void OnGUI() {
if (mood1 ==1) {
GUI.color = Color.green;
GUI.backgroundColor = Color.black;
GUI.Box (new Rect (10, 40, 150, 25), "Rotating Head");
}
else if (mood1 ==2) {
GUI.color = Color.red;
GUI.backgroundColor = Color.black;
GUI.Box(new Rect (10,40,150,25),"Rotating Plane");
}
}
}