BITFALL/Assets/BITKit/Unity/Scripts/Selection/Selectable.cs

59 lines
1.8 KiB
C#
Raw Normal View History

2023-10-20 19:31:12 +08:00
using System;
2023-06-08 14:09:50 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
public class Selectable : MonoBehaviour, ISelectable
{
public Transform GetTransform() => transform;
2023-10-20 19:31:12 +08:00
private void Start()
2023-06-08 14:09:50 +08:00
{
2023-10-20 19:31:12 +08:00
OnNone?.Invoke();
2023-06-08 14:09:50 +08:00
}
2023-11-30 00:23:23 +08:00
public Transform Transform =>this? transform:null;
2023-06-08 14:09:50 +08:00
public void SetSelectionState(SelectionState state)
{
2023-10-20 19:31:12 +08:00
switch (state)
2023-06-08 14:09:50 +08:00
{
2023-10-20 19:31:12 +08:00
case SelectionState.None:
OnNone?.Invoke();
break;
case SelectionState.Hover:
OnHover?.Invoke();
break;
case SelectionState.Active:
OnActive?.Invoke();
break;
case SelectionState.Inactive:
OnInactive?.Invoke();
break;
case SelectionState.Focus:
OnFocus?.Invoke();
break;
case SelectionState.Selected:
OnSelected?.Invoke();
break;
case SelectionState.Enabled:
OnEnabled?.Invoke();
break;
case SelectionState.Checked:
OnChecked?.Invoke();
break;
case SelectionState.Root:
OnRoot?.Invoke();
break;
2023-06-08 14:09:50 +08:00
}
}
2023-10-20 19:31:12 +08:00
public event Action OnNone;
public event Action OnHover;
public event Action OnActive;
public event Action OnInactive;
public event Action OnFocus;
public event Action OnSelected;
public event Action OnEnabled;
public event Action OnChecked;
public event Action OnRoot;
2023-06-08 14:09:50 +08:00
}
}