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()
{

View File

@@ -71,6 +71,7 @@ namespace BITKit.UX
/// </summary>
public static void ClearHistory() => History.Clear();
public string SettingsPath { get; set; } = "ux_panel_settings";
public object Root { get; private set; }
public async UniTask InitializeAsync()
{
@@ -86,7 +87,7 @@ Object.Destroy(gameObject);
var document = gameObject.AddComponent<UIDocument>();
try
{
var panelSettings =await ModService.LoadAsset<PanelSettings>("ux_panel_settings");
var panelSettings =await ModService.LoadAsset<PanelSettings>(SettingsPath);
document.panelSettings = panelSettings;
}
catch (Exception e)