This commit is contained in:
CortexCore
2025-01-12 11:13:19 +08:00
parent 01e7e4e35e
commit 01b3d1be43
26 changed files with 387 additions and 336 deletions

View File

@@ -18,7 +18,7 @@ using Debug = UnityEngine.Debug;
namespace BITKit.UX
{
public abstract class UIToolKitPanel : IUXPanel
public abstract class UIToolKitPanel : IUXPanel,IDisposable
{
public const string USSEntry = "transition_entry";
public const string USSEntryAsync = "transition_entry_async";
@@ -128,6 +128,7 @@ namespace BITKit.UX
public virtual bool AllowCursor { get; }
public virtual bool AllowInput { get; }
public virtual string[] InitialUssClasses { get; } = Array.Empty<string>();
public bool IsDisposed { get; private set; }
public bool IsEntered { get; set; }
protected virtual void OnReturn()
@@ -247,6 +248,12 @@ namespace BITKit.UX
public virtual void OnTick(float deltaTime)
{
}
public void Dispose()
{
RootVisualElement?.RemoveFromHierarchy();
IsDisposed = true;
}
}
}

View File

@@ -13,6 +13,7 @@ namespace BITKit.UX
protected readonly IUXService UXService;
protected VisualElement RootVisualElement { get; set; }
protected bool IsInitialized { get; private set; }
protected readonly UniTaskCompletionSource WaitUntilInitialized = new();
protected UIToolkitOverlay(IUXService uxService, CancellationTokenSource cancellationToken)
{
UXService = uxService;
@@ -40,6 +41,8 @@ namespace BITKit.UX
UXUtils.Inject(this);
IsInitialized = true;
WaitUntilInitialized.TrySetResult();
}
public virtual void Dispose()
{