Hi, I was unable to run a script to change the image of a button.
Script: (C#)
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
public class Bouton123 : MonoBehaviour {
public Button button;
public Sprite Image1;
void Start () {
button = GetComponent<Button>();
button.image.sprite = Image1;
}
void Update () {
}
}
Error: “NullReferenceException: Object reference not set to an instance of an object”
Someone can help me ?