我圈中的那***哪里,不能没办法获取到image组件
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
}
}
最后记住,在图片哪里我们需要换一下类型,不然没办法修改他的图片
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)