Files
Net.Like.Xue.Tokyo/Packages-Local/Com.Project.B.Unity/PDA/PDAApp.cs
2025-06-24 23:49:13 +08:00

47 lines
1.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.Mod;
using BITKit.StateMachine;
using BITKit.UX;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UIElements;
namespace Net.Project.B.PDA
{
public abstract class PDAApp<T>:StateAsync,IAppClass<T> where T:IApp,new()
{
public Type AppType => typeof(T);
public readonly T App = new T();
protected PDAApp()
{
Routes = new[] {$"/{GetType().Name}" };
}
public IReadOnlyList<string> Routes { get; }
public virtual UniTask<object> GetPage(string route)
{
RootVisualElement.Navigate(route);
return UniTask.FromResult<object>(RootVisualElement);
}
protected abstract string DocumentPath { get; }
protected VisualElement RootVisualElement { get; private set; }
public override async UniTask InitializeAsync()
{
var template = await ModService.LoadAsset<VisualTreeAsset>(DocumentPath);
RootVisualElement = template.CloneTree();
UXUtils.Inject(this,RootVisualElement);
}
}
}