46 lines
1.8 KiB
C#
46 lines
1.8 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
namespace BITKit
|
|
{
|
|
public class SelectableEvent : MonoBehaviour
|
|
{
|
|
[Header(nameof(SelectionState.None))]
|
|
[SerializeField] private UnityEvent OnNone;
|
|
[Header(nameof(SelectionState.Hover))]
|
|
[SerializeField]private UnityEvent OnHover;
|
|
[Header(nameof(SelectionState.Active))]
|
|
[SerializeField]private UnityEvent OnActive;
|
|
[Header(nameof(SelectionState.Inactive))]
|
|
[SerializeField]private UnityEvent OnInactive;
|
|
[Header(nameof(SelectionState.Focus))]
|
|
[SerializeField]private UnityEvent OnFocus;
|
|
[Header(nameof(SelectionState.Selected))]
|
|
[SerializeField]private UnityEvent OnSelected;
|
|
[Header(nameof(SelectionState.Enabled))]
|
|
[SerializeField]private UnityEvent OnEnabled;
|
|
[Header(nameof(SelectionState.Checked))]
|
|
[SerializeField]private UnityEvent OnChecked;
|
|
[Header(nameof(SelectionState.Root))]
|
|
[SerializeField]private UnityEvent OnRoot;
|
|
private void Start()
|
|
{
|
|
var selectable = GetComponent<ISelectable>();
|
|
if (selectable == null)
|
|
{
|
|
Debug.LogError($"No {nameof(ISelectable)} component found on {gameObject.name}");
|
|
return;
|
|
}
|
|
selectable.OnNone += OnNone.Invoke;
|
|
selectable.OnHover += OnHover.Invoke;
|
|
selectable.OnActive += OnActive.Invoke;
|
|
selectable.OnInactive += OnInactive.Invoke;
|
|
selectable.OnFocus += OnFocus.Invoke;
|
|
selectable.OnSelected += OnSelected.Invoke;
|
|
selectable.OnEnabled += OnEnabled.Invoke;
|
|
selectable.OnChecked += OnChecked.Invoke;
|
|
selectable.OnRoot += OnRoot.Invoke;
|
|
|
|
}
|
|
}
|
|
} |