UGUI怎么获取Image,怎么动态的更换Image
1个回答
展开全部
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Sprites;
public class OnButton : MonoBehaviour {
private Button button;
private Image image;
void Start () {
button=this.GetComponent<Button>();
image=this.GetComponent<Image>();
}
private void ButtonDown()
{
button.interactable=false; image.overrideSprite=Resources.Load("Textures/TechBlue/background",typeof(Sprite))as Sprite;//这里就是修改他的图片,
image.color=Color.red;
}
}
using System.Collections;
using UnityEngine.UI;
using UnityEngine.Sprites;
public class OnButton : MonoBehaviour {
private Button button;
private Image image;
void Start () {
button=this.GetComponent<Button>();
image=this.GetComponent<Image>();
}
private void ButtonDown()
{
button.interactable=false; image.overrideSprite=Resources.Load("Textures/TechBlue/background",typeof(Sprite))as Sprite;//这里就是修改他的图片,
image.color=Color.red;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询