1
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user