public GameObject _background; public UIAtlas atlas; private Dictionary<int, UISprite> _allCardSprite; for (int i=0; i<10; ++i) { GameObject _parent = NGUITools.AddChild (_background); _parent.name = "cards"; _parent.transform.localPosition = new Vector3 (i*10, 200.0f, 0.0f); UISprite _sprite = NGUITools.AddWidget<UISprite>(_parent); _sprite.atlas = atlas; _sprite.depth = i; _sprite.name = i.ToString(); _sprite.spriteName = i.ToString(); _allCardSprite.Add(i, _sprite); _sprite.MakePixelPerfect(); } foreach (KeyValuePair<int, UISprite> pair in _allCardSprite){ TweenPosition _position = pair.Value.gameObject.GetComponent<TweenPosition>(); if (_position == null){ _position = pair.Value.gameObject.AddComponent<TweenPosition> (); } _position.duration = 0.2f; _position.delay = pair.Key*0.2f; _position.from = new Vector3(0.0f, 0.0f, 0.0f); _position.to = new Vector3(0.0f, -200.0f, 0.0f); _position.PlayForward(); } //动态加载头像:GameObject _look = Resources.Load ("HeroPanel", typeof(GameObject)) as GameObject;GameObject go = NGUITools.AddChild (_background, _look);go.transform.position = new Vector3 (0.0f, 0.0f, 0.0f); //相对中心坐标原点
ngui 脚本绘制sprite,布布扣,bubuko.com
时间: 2024-10-29 19:11:21