This commit is contained in:
CortexCore
2023-10-24 23:38:22 +08:00
parent 2c4710bc5d
commit bd40165ade
152 changed files with 3681 additions and 1531 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -6,21 +7,53 @@ namespace BITKit
public class Selectable : MonoBehaviour, ISelectable
{
public Transform GetTransform() => transform;
ISelectableComponent[] components;
void Start()
private void Start()
{
components = GetComponentsInChildren<ISelectableComponent>(true);
foreach (var x in components)
{
x.SetSelectionState(0);
}
OnNone?.Invoke();
}
public Transform Transform => transform;
public void SetSelectionState(SelectionState state)
{
foreach (var x in components)
switch (state)
{
x.SetSelectionState(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;
}
}
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;
}
}