using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BuildManager : MonoBehaviour
void Start() {
}
void Update() {
}
void OnMouseEnter()
{
transform.GetChild(0).GetComponent<Image>().color = Color.green;
}
void OnMouseExit()
{
transform.GetChild(0).GetComponent<Image>().color = Color.white;
}
}
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Assets.Scripts
{
public class BuildManager : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
private Image _image;
void Start()
{
_image = GetComponent<Image>();
if (_image is null)
{
throw new NullReferenceException(
$"The component of the type \"{nameof(Image)}\" not found.");
}
}
void Update()
{
}
public void OnPointerEnter(PointerEventData eventData)
{
_image.color = Color.green;
}
public void OnPointerExit(PointerEventData eventData)
{
_image.color = Color.white;
}
}
}