ITeye博客

NGUI动态创建UILabel

wgcode · 2015-05-13 14:32 · Unity · 移动开发 · Markdown

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";
    }
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。