30 lines
549 B
C#
30 lines
549 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIMenuItem : MonoBehaviour
|
|
{
|
|
public delegate void MenuItemAction();
|
|
|
|
public event MenuItemAction action;
|
|
|
|
public bool IsSelected { get; private set; }
|
|
|
|
private Image background;
|
|
|
|
private void Awake()
|
|
{
|
|
background = GetComponent<Image>();
|
|
}
|
|
|
|
public void SetSelected(bool selected)
|
|
{
|
|
IsSelected = selected;
|
|
background.color = selected ? Color.gray : Color.white;
|
|
}
|
|
|
|
public void OnClick()
|
|
{
|
|
action?.Invoke();
|
|
}
|
|
}
|