NGUI动态创建UILabel

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour
{
    public GameObject testBtn;
    public Font f;
    // Use this for initialization
    void Start()
    {
        UIEventListener.Get(testBtn).onClick += CreatLabel;
    }

    // Update is called once per frame
    void Update()
    {

    }

    void CreatLabel(GameObject go)
    {
        UILabel label = NGUITools.AddChild<UILabel>(gameObject);
        label.trueTypeFont = f;
        label.text = "Test";
    }
}

猜你喜欢

转载自tts.iteye.com/blog/2210788