UGUI动态更换图片

来源:互联网 发布:db2数据库客户端下载 编辑:程序博客网 时间:2024/05/22 05:30
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class Pai : MonoBehaviour {


    void Start()
    {
        Texture2D img = Resources.Load("Game/BJHH/MahJong/hand/1") as Texture2D;


        Sprite pic = Sprite.Create(img, new Rect(0, 0, img.width, img.height), Vector2.zero);


        Image ico = GetComponent<Image>();
        ico.sprite = pic;


    }
}
原创粉丝点击