UGUI怎么获取Image,怎么动态的更换Image
怎么动态来修改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;
}
}
最后记住,在图片哪里我们需要换一下类型,不然没办法修改他的图片
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。