更改文件架构

This commit is contained in:
CortexCore
2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 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,11 @@
fileFormatVersion: 2
guid: f51350f9724ab8a41831d6bc51d65bf5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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,11 @@
fileFormatVersion: 2
guid: eb2d5a09faa2e9a41858ff98770b423c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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,11 @@
fileFormatVersion: 2
guid: cc54ec95ef8983c43ba8ef43dae16792
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ad098f307334e54dbcffd896748414c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: