NGUI使用图集的精灵换图片
2015-09-10 20:49
399 查看
创建了一个sprite,选择的是某一个图集下的sprite,现在我想点击它来换图片。前提是你的sprite已经加了UIButton
代码如下:
这个可以做对话,但是不推荐,比如你的对话有五十个,那你要用五十张图片。。。
代码如下:
public void OnClick() { if (this.GetComponent<UIButton>().normalSprite == "picture1") { this.GetComponent<UISprite>().spriteName = "picture2"; this.GetComponent<UIButton>().normalSprite = "picture2"; return; } if (this.GetComponent<UIButton>().normalSprite == "picture2") { this.GetComponent<UISprite>().spriteName = "picture1"; this.GetComponent<UIButton>().normalSprite = "picture1"; return; } }
这个可以做对话,但是不推荐,比如你的对话有五十个,那你要用五十张图片。。。
相关文章推荐
- IOS-UI-视图控件UIview
- iOS:集合视图UICollectionView、集合视图控制器UICollectionViewController、集合视图单元格UICollectionViewCell(创建表格的另一种控件)
- CodeForces 11A - Increasing Sequence
- Illegal instant due to time zone offset transition (Asia/Shanghai)
- HDU4620 Fruit Ninja Extreme(搜索+剪枝)
- HotSpot Builder Utility安装指南
- 用UITextView加载rtfd文件
- Android UI 优化方向
- UITableView 基础知识
- String,StringBuffer和StringBuilder的区别
- MAC上反编译android apk---apktool, dex2jar, jd-jui安装使用(含手动签名)
- HDU_1242_Rescue
- 安卓常见错误处理记录5:安卓系统编译报错 finished with non-zero exit value -1073741819
- hdu 5312 Sequence(数学推导+线性探查(两数相加版))
- [leetcode]Word Frequency
- easyui表单验证
- Axure 交互设计 (1)
- mysql高速缓存query_cache参数调优
- UINavigationController视图控制器切换(一)
- 【ZJOI2012】【BZOJ2656】数列(sequence)