unity动态加载UGUI图片

工作中用到点击UI图片切换成另外一个图片,不说废话直接上代码

using UnityEngine.UI;//UI引用
  Texture2D t;
  public Image Mute;
 public void Mute_()
    {
       
            t = (Texture2D)Resources.Load("picture/静音");
            Sprite temp = Sprite.Create(t, new Rect(0, 0, t.width, t.height), new Vector2(0, 0));
            Mute.sprite = temp;
          
      
    }

你可能感兴趣的:(unity基础,C#,unity)