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

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

usingUnityEngine;
usingSystem.Collections;
usingUnityEngine.UI;
usingUnityEngine.Sprites;
publicclassOnButton:MonoBehaviour{

privateButtonbutton;
privateImagep_w_picpath;

voidStart(){

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

}


privatevoidButtonDown()
{

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

}
}


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