I am trying to make a main menu in unity with multiple images problem is i cant figure out how to go about creating code to change the image when you hover over the button with your mouse.
here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class imagechange : MonoBehaviour
{
[SerializeField] private Image newimage;
[SerializeField] private Image oldimage;
private void OnMouseEnter()
{
//this will change the image from not hovered to hovered
newimage.enabled = true;
oldimage.enabled = false;
}
private void OnMouseExit()
{
//this will change the image from hovered to not hovered
newimage.enabled = false;
oldimage.enabled = true;
}
}
i cant get the images into the variables so I can change the image.