NGUI的代码控制
2015-08-22 03:58
375 查看
NGUI的代码控制
1、代码操作NGUI
using UnityEngine; using System.Collections; public class ChangeColor : MonoBehaviour { // Use this for initialization void Start () { UISprite theSprite = this.GetComponent<UISprite>(); theSprite.color = Color.red; } // Update is called once per frame void Update () { } }
与此类似:
UILabel、UISprite、UITexture、UIButton、UIGrid、UISlider、UIToggle、UIInput、UIPanel、UICamera。等
都可以有用类似:
UISprite theSprite = this.GetComponent<UISprite>();
得到。
2、动态加载UI元素
using UnityEngine; using System.Collections; public class LoadPrefab : MonoBehaviour { public GameObject prefab; // Use this for initialization void Start () { GameObject newObj = NGUITools.AddChild(this.gameObject, prefab); } // Update is called once per frame void Update () { } }
相关文章推荐
- UITextField 光标的位置设置获取
- iOS:UITextField中文输入法输入时对字符长度的限制
- 线程自动加锁与自动解锁:lock_guard & unique_lock
- STM32F2x Is it possible to request multiple DMA streams with single request
- [工具类]基于easyui的页面等待提示层,即mask
- Timer triggered DMA transfer - Delay between requesting the DMA transfer
- HDU - 4126 Genghis Khan the Conqueror(树形DP + 最小生成树)
- POJ 2299 Ultra-QuickSort(求逆序数)
- UI_06 UIControl及其子类
- UIAlerViewController的使用
- SPOJ 3267 DQUERY(主席树在线|树状数组离线)
- UISlider的使用
- Easy Ui Layout控件
- iOS上用GPUImage给视频加滤镜
- [LeetCode] Unique Paths II
- With one file handling all requests, you can centralize things such as security handling, configurat
- hdu 5412 CRB and Queries(线段树套笛卡尔树 - 动态区间第k大)
- Android问题:设置了requestWindowfeature(window.feature_no_title)后,为什么还要getwindow.setFlags?
- Android UI设计——EditText控件
- EasyUI的progress对象close方法报错的彻底解决方案,easyuiprogress