This commit is contained in:
CortexCore
2023-06-05 16:25:06 +08:00
parent 9027120bb8
commit 4565ff2e35
2947 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RotaryHeart.Lib.SerializableDictionary;
using UnityEngine.Events;
namespace BITKit
{
public class SubSelectable : MonoBehaviour, ISelectable
{
Selectable root;
public Transform GetTransform() => root.GetTransform();
public void SetSelectionState(SelectionState state)
{
root.SetSelectionState(state);
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
public enum SelectionState
{
None,
Hover,
Active,
Inactive,
Focus,
Selected,
Enabled,
Checked,
Root,
}
public interface ISelectable
{
Transform GetTransform();
void SetSelectionState(SelectionState state);
}
public interface ISelectableCallback
{
void OnHover(ISelectable selectable);
void OnActive(ISelectable selectable);
void OnInactive(ISelectable selectable);
}
public interface ISelectableComponent
{
void SetSelectionState(SelectionState state);
}
}

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
public class Selectable : MonoBehaviour, ISelectable
{
public Transform GetTransform() => transform;
ISelectableComponent[] components;
void Start()
{
components = GetComponentsInChildren<ISelectableComponent>(true);
foreach (var x in components)
{
x.SetSelectionState(0);
}
}
public void SetSelectionState(SelectionState state)
{
foreach (var x in components)
{
x.SetSelectionState(state);
}
}
}
}

View File

@@ -0,0 +1,59 @@
using UnityEngine;
using UnityEngine.Events;
namespace BITKit
{
public class SelectableEvent : MonoBehaviour, ISelectableComponent
{
[Header(nameof(SelectionState.None))]
[SerializeField] UnityEvent OnNone;
[Header(nameof(SelectionState.Hover))]
[SerializeField] UnityEvent OnHover;
[Header(nameof(SelectionState.Active))]
[SerializeField] UnityEvent OnActive;
[Header(nameof(SelectionState.Inactive))]
[SerializeField] UnityEvent OnInactive;
[Header(nameof(SelectionState.Focus))]
[SerializeField] UnityEvent OnFocus;
[Header(nameof(SelectionState.Selected))]
[SerializeField] UnityEvent OnSelected;
[Header(nameof(SelectionState.Enabled))]
[SerializeField] UnityEvent OnEnabled;
[Header(nameof(SelectionState.Checked))]
[SerializeField] UnityEvent OnChecked;
[Header(nameof(SelectionState.Root))]
[SerializeField] UnityEvent OnRoot;
public void SetSelectionState(SelectionState state)
{
switch (state)
{
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;
}
}
}
}