- Home /
How to add some element in the scene of a Camera
I'm beginner and I want to develop a aircraft simulator with first person view and third person view. I have import the airplane model and set the cameras.
----Now I want to display the longitude/latitude/altitude in the scene of both cameras. How to do? GUI Label? Please tell me in details. 3Q!
----how to make instrument panel in the camera to indicate angle of pitch? Is there anything that can help?
PS: Unity 4.6 UGUI environment
Answer by blueLED · Nov 13, 2014 at 11:54 AM
private float longitude; //assign the planes x, y, and z values in update for these variables
private float latitude;
private float altitude;
void OnGUI() {
GUI.Label (new Rect (25, 25, 100, 30), "Longitude: " + longitude + " Latitude: " + latitude + " Altitude: " + altitude);
}
Pitch is based on the rotation of the plane, so it's the same principle.
As added above, the enviroment is Unity 4.6 with UGUI. There is only text ins$$anonymous$$d of Label. I have add the object on screen. But how to control its visibility?
The text GameObject is named by "LonLat";
I have tried LonLat.setActive() and LonLat.renderer.setActive() but both failed. In the first method there is no response and in the other unity exits with an unkown error!