首页 > 其他 > 详细

(NGUI)UISprite 切换图集

时间:2014-10-29 23:38:19      阅读:394      评论:0      收藏:0      [点我收藏+]

UISprite是可以使用代码动态切换图集的

using UnityEngine;
using System.Collections;

public class SpriteAtlasTest : MonoBehaviour {

    private UISprite _sprite;
    public UIAtlas atlas;
    public UIAtlas atlas2;
    // Use this for initialization
    void Start () {
        _sprite = GetComponent<UISprite>();
    }
    
    // Update is called once per frame
    void Update () {
       

        if(Input.GetMouseButtonDown(0))
        {
            _sprite.atlas = atlas;
            _sprite.spriteName = "GoodDirt";
           
            
        }
        if(Input.GetMouseButtonDown(1))
        {
            _sprite.atlas = atlas2;
            _sprite.spriteName = "NGUI";
        }
    }
}

bubuko.com,布布扣

bubuko.com,布布扣

 

这样就是使用UISprite来制作图标了,比如物品图标,可以分别存在不同的图集里面,根据配置物品icon在哪一个图集,在需要显示的时候动态指定图集就可以了~

(NGUI)UISprite 切换图集

原文:http://www.cnblogs.com/wonderKK/p/4060572.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!