更改文件架构
This commit is contained in:
17
Packages/Common~/Scripts/Selection/ColliderSelectable.cs
Normal file
17
Packages/Common~/Scripts/Selection/ColliderSelectable.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f51350f9724ab8a41831d6bc51d65bf5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Packages/Common~/Scripts/Selection/ISelectable.cs
Normal file
33
Packages/Common~/Scripts/Selection/ISelectable.cs
Normal 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);
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Selection/ISelectable.cs.meta
Normal file
11
Packages/Common~/Scripts/Selection/ISelectable.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb2d5a09faa2e9a41858ff98770b423c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Packages/Common~/Scripts/Selection/Selectable.cs
Normal file
26
Packages/Common~/Scripts/Selection/Selectable.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Selection/Selectable.cs.meta
Normal file
11
Packages/Common~/Scripts/Selection/Selectable.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc54ec95ef8983c43ba8ef43dae16792
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
59
Packages/Common~/Scripts/Selection/SelectableEvent.cs
Normal file
59
Packages/Common~/Scripts/Selection/SelectableEvent.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Packages/Common~/Scripts/Selection/SelectableEvent.cs.meta
Normal file
11
Packages/Common~/Scripts/Selection/SelectableEvent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ad098f307334e54dbcffd896748414c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user