ugui根据图名动态切换Image图片

来源:互联网 发布:网络电影票房 编辑:程序博客网 时间:2024/05/06 00:35
  1. 点击图片,将图片的Textrue Type设置为Sprite(2DandUI)
  2. 将需要的图片放在Assets下的Resources下
  3. 上代码
    using UnityEngine.UI;//需要引入的头文件    public Image myImage;//获取需要切换图片的Image    myImage.sprite = Resources.Load("图片名", typeof(Sprite)) as Sprite;//动态改变图片,代码可写在需要变图片的位置上
原创粉丝点击