NGUI动态创建UILabel

欢迎来到unity学习unity培训、unity企业培训教育专区,这里有很多U3D资源U3D培训视频U3D教程U3D常见问题U3D项目源码,我们致力于打造业内unity3d培训、学习第一品牌。

 

 

下面我们开始今天的Unity3D技能培训。 我们学习Unity3D培训目标:让U3D初学者可以更快速的掌握U3D技术,自行制作修改素材,可以独立完成2D、3D小规模游戏及网页游戏开发。

[csharp] view plaincopy

 

 

  1. using UnityEngine;  
  2. using System.Collections;  
  3.   
  4. public class Test : MonoBehaviour  
  5. {  
  6.     public GameObject testBtn;  
  7.     public Font f;  
  8.     // Use this for initialization  
  9.     void Start()  
  10.     {  
  11.         UIEventListener.Get(testBtn).onClick += CreatLabel;  
  12.     }  
  13.   
  14.     // Update is called once per frame  
  15.     void Update()  
  16.     {  
  17.   
  18.     }  
  19.   
  20.     void CreatLabel(GameObject go)  
  21.     {  
  22.         UILabel label = NGUITools.AddChild<UILabel>(gameObject);  
  23.         label.trueTypeFont = f;  
  24.         label.text = "Test";  
  25.     }  

 

 

更多精彩请点击 http://www.gopedu.com/

posted on 2014-10-14 17:30  狗刨学习网  阅读(871)  评论(0编辑  收藏  举报