Cómo modificar la fuente UILabel de ngui mediante script
El objetivo en la etiqueta está vacío y agregamos dinámicamente el objeto Target en el evento OnClick de FloatingTextDriver.
Aquí está la implementación de las clases FloatingTextDriver y FloatingText:
Código fuente
Usando UnityEngine
Usando System.
clase pública Fl www.hnnedu.com oatingTextDriver: MonoBehaviour {
objetivo de GameObject público;
texto flotante público ft;
fuente UIFont pública;
IEnumerator OnClick()
{
ft.Target = objetivo;
ft.Text = "libufan";
ft .Active = true;
rendimiento return new WaitForSeconds(2.0f);
ft.Font = font;
ft.FontSize = new Vector3(50, 50, 1);
}
}
Código fuente
usando UnityEngine;
usando System. Colecciones;
clase pública Texto flotante: MonoBehaviour {
UILabel privada _lbl;
GameObject público _target;
Cámara pública worldCamera; p> p>
Cámara pública guiCamera;
privada Vector3 www.hbbz08.com pubPos
privada bool _active;
void Awake()
{
_lbl = GetComponent
if(_lbl == null)
{
Debug.LogError("¡No se pudo encontrar UILabel!");
}
}
}
void Start( )
{
guiCamera = NGUITools.FindCameraForLayer( gameObject.layer);
}
Color público TextColor
{
get {return _lbl.color;}
set {_lbl.color = value;}
}
público texto de cadena
{
get { return _lbl.text }
set { _lbl.text = valor }
}
texto de cadena pública
{
get { return _lbl.text }
set { _lbl.text = valor } p>
}