Sprite精灵图片

public class L3 : MonoBehaviour
{
    public UISprite sprite;
    // Start is called before the first frame update
    void Start()
    {
        //Sprite作用
        //NGUI中所有中小尺寸图片都用Sprite显示
        //用它来显示图集中的单个图片资源
        //可以理解为一个图片控件

        //Sprite中的参数
        //Type - Simple 缩放会拉伸
        //Sliced - 这个模式要搭配Sprite设置里的Border使用
        //Widget
        //Pivot-控制对象的中心点
        //Depth 决定渲染顺序

        //代码设置图片
        //改变为当前图集里面别的图片
        sprite.spriteName = "bk";
        //改变为另一个图集中的图片
        NGUIAtlas atlas = Resources.Load<NGUIAtlas>("Atlas/login");
        sprite.spriteName = "bkb";
    }
}

posted @ 2025-03-22 20:18  cannedmint  阅读(12)  评论(0)    收藏  举报