Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// Este script se adjunta al GameObject que quiere mostrar su etiqueta
- /// En este caso al Cube
- /// En este ejemplo se muestra el funcionamiento de WorldToScreenPoint y como mostrar etiquetas
- /// Tambien con NGUI, descomentar las 2 lineas debajo de //NGUI
- /// </summary>
- public class mundo : MonoBehaviour {
- public GameObject ngui_barra;
- public Camera camara2;
- void Start () {
- ngui_barra = GameObject.Find ("barra");
- }
- // Update is called once per frame
- void Update () {
- }
- void OnGUI()
- {
- //NGUI
- // Vector3 pos_pantala = Camera.main.WorldToScreenPoint (transform.position);
- // ngui_barra.transform.position = camara2.ScreenToWorldPoint( pos_pantala);
- //UNITY
- Vector3 pos_pantala = Camera.main.WorldToScreenPoint (transform.position);
- float escala = pos_pantala.z / 10;
- GUIStyle st = new GUIStyle ();
- st.fontSize = Mathf.CeilToInt( 20/escala);
- st.alignment = TextAnchor.MiddleCenter;
- GUI.Label(new Rect(pos_pantala.x - 70/2/escala, Screen.height - pos_pantala.y -40/escala, 70/escala, 20/escala), "Etiqueta",st);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment