Ver.0.3.0.33
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
public class BaseButton : Button
|
||||
{
|
||||
public SelectionType CurSelectionState => TransStateToType(currentSelectionState);
|
||||
|
||||
public UnityEvent<SelectionType, bool> onStateTransition = new();
|
||||
|
||||
protected override void DoStateTransition(SelectionState state, bool instant)
|
||||
{
|
||||
if (!gameObject.activeInHierarchy)
|
||||
return;
|
||||
|
||||
onStateTransition?.Invoke(TransStateToType(state), instant);
|
||||
}
|
||||
|
||||
protected static SelectionType TransStateToType(SelectionState state)
|
||||
{
|
||||
return Enum.Parse<SelectionType>(state.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 因为作用域问题把枚举转出来用
|
||||
/// </summary>
|
||||
public enum SelectionType
|
||||
{
|
||||
/// <summary>
|
||||
/// The UI object can be selected.
|
||||
/// </summary>
|
||||
Normal,
|
||||
|
||||
/// <summary>
|
||||
/// The UI object is highlighted.
|
||||
/// </summary>
|
||||
Highlighted,
|
||||
|
||||
/// <summary>
|
||||
/// The UI object is pressed.
|
||||
/// </summary>
|
||||
Pressed,
|
||||
|
||||
/// <summary>
|
||||
/// The UI object is selected
|
||||
/// </summary>
|
||||
Selected,
|
||||
|
||||
/// <summary>
|
||||
/// The UI object cannot be selected.
|
||||
/// </summary>
|
||||
Disabled
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user