头像制作

目前不知道怎么实现动态加载,可以换种思路来做做

1、制作头像的atlas

2、新建一个PlayerPanel(UIPanel),Depth设置为2(具体根据图层设置),PlayerPanel下新建三个组件username(UILable)、avatar(UISprite)、account(UILable)

3、将PlayerPanel拖入Resources文件夹,制作成prefab

4、场景UI Root->Camera->Anchor->Panel绑定脚本xxx, 脚本定义变量,将PlayerPanel预制绑定

5、Start ()编辑脚本:

GameObject go = NGUITools.AddChild(this.gameObject, _hero);  
go.name = "动态";  
go.transform.localPosition = new Vector3(go.transform.localPosition.x, 0, go.transform.localPosition.z);  

UISprite avatar = go.GetComponentInChildren<UISprite> ();
avatar.spriteName = "2";

UILabel[] _lable = go.GetComponentsInChildren<UILabel> ();
_lable [0].text = "100";

 

6、如果要销毁对象: Destroy(go);

posted @ 2014-07-23 16:57  Zhaoyier  阅读(204)  评论(0编辑  收藏  举报