1
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using BITKit.Mod;
|
||||
using BITKit.StateMachine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
@@ -18,7 +19,7 @@ using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public abstract class UIToolKitPanel : IUXPanel,IDisposable
|
||||
public abstract class UIToolKitPanel :StateAsync, IUXPanel,IDisposable
|
||||
{
|
||||
public const string USSEntry = "transition_entry";
|
||||
public const string USSEntryAsync = "transition_entry_async";
|
||||
@@ -115,7 +116,7 @@ namespace BITKit.UX
|
||||
//WaitUtilTransitionCompleted = new();
|
||||
}
|
||||
|
||||
protected static readonly InputActionGroup InputActionGroup = new()
|
||||
protected readonly InputActionGroup InputActionGroup = new()
|
||||
{
|
||||
allowGlobalActivation = false,
|
||||
Source = nameof(UIToolKitPanel)
|
||||
@@ -137,13 +138,12 @@ namespace BITKit.UX
|
||||
}
|
||||
protected virtual void OnPanelEntry(){}
|
||||
protected virtual void OnPanelExit(){}
|
||||
|
||||
void IEntryElement.Entry()
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
InputActionGroup.allowInput.AddElement(this);
|
||||
OnEntry?.Invoke();
|
||||
}
|
||||
async UniTask IEntryElement.EntryAsync()
|
||||
public override async UniTask OnStateEntryAsync(IState old)
|
||||
{
|
||||
await InitializeAsync();
|
||||
|
||||
@@ -193,6 +193,12 @@ namespace BITKit.UX
|
||||
await UniTask.SwitchToMainThread();
|
||||
|
||||
RootVisualElement.AddToClassList(USSEntered);
|
||||
|
||||
OnPanelEntry();
|
||||
OnEntryCompleted?.Invoke();
|
||||
|
||||
RootVisualElement.RemoveFromClassList(USSEntry);
|
||||
RootVisualElement.RemoveFromClassList(USSEntryAsync);
|
||||
}
|
||||
private void OnTransitionEnd<TChangeEvent>(TChangeEvent evt)
|
||||
{
|
||||
@@ -203,22 +209,15 @@ namespace BITKit.UX
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
void IEntryElement.Entered()
|
||||
{
|
||||
OnPanelEntry();
|
||||
OnEntryCompleted?.Invoke();
|
||||
|
||||
RootVisualElement.RemoveFromClassList(USSEntry);
|
||||
RootVisualElement.RemoveFromClassList(USSEntryAsync);
|
||||
}
|
||||
|
||||
void IEntryElement.Exit()
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
OnPanelExit();
|
||||
InputActionGroup.allowInput.RemoveElement(this);
|
||||
OnExit?.Invoke();
|
||||
}
|
||||
async UniTask IEntryElement.ExitAsync()
|
||||
|
||||
public override async UniTask OnStateExitAsync(IState old, IState newState)
|
||||
{
|
||||
RootVisualElement?.RemoveFromClassList(USSEntered);
|
||||
await UniTask.NextFrame();
|
||||
@@ -244,9 +243,6 @@ namespace BITKit.UX
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
void IEntryElement.Exited()
|
||||
{
|
||||
RootVisualElement?.RemoveFromClassList(USSExit);
|
||||
RootVisualElement?.RemoveFromClassList(USSExitAsync);
|
||||
RootVisualElement?.AddToClassList(USSExited);
|
||||
@@ -275,6 +271,7 @@ namespace BITKit.UX
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
InputActionGroup.Dispose();
|
||||
RootVisualElement?.RemoveFromHierarchy();
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user