UGUI怎么获取Image,怎么动态的更换Image

发布时间:2020-07-09 12:47:32 作者:酷酷小乔
来源:网络 阅读:17010

    怎么动态来修改UGUI中的p_w_picpath呢,怎么来获取这个组件呢 ,首先我们需要在头文件里面定义一下 

我圈中的那***哪里,不能没办法获取到p_w_picpath组件

     using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Sprites;
public class OnButton : MonoBehaviour {

   private Button button;
   private Image p_w_picpath;
    
    void Start () {

    button=this.GetComponent<Button>();
    p_w_picpath=this.GetComponent<Image>();

    }

 
    private void ButtonDown()
    {

    button.interactable=false;           p_w_picpath.overrideSprite=Resources.Load("Textures/TechBlue/background",typeof(Sprite))as Sprite;//这里就是修改他的图片,
    p_w_picpath.color=Color.red;

    }
}


最后记住,在图片哪里我们需要换一下类型,不然没办法修改他的图片


推荐阅读:
  1. Reason: image not found
  2. docker image镜像的发布

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

ugui 获取image组件 更换图片

上一篇:STC15点亮WS2812灯珠(C结合汇编)

下一篇:linux命令基础(一)

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》