broken
This commit is contained in:
38
Runtime/Engine/Code/UI/UIDocumentView.cs
Normal file
38
Runtime/Engine/Code/UI/UIDocumentView.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using UnityEngine.UIElements;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootKit.Engine.UI {
|
||||
public abstract class UIDocumentView : MonoBehaviour, IView, IVisualElementBuilder {
|
||||
static readonly Logger s_logger = new(nameof(UIDocumentView));
|
||||
|
||||
[SerializeField] UIDocument m_Document;
|
||||
|
||||
void OnEnable() {
|
||||
s_logger.Debug("START");
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
public async UniTask Show(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
public async UniTask Hide(CancellationToken cancellationToken) {
|
||||
await UniTask.Yield(cancellationToken);
|
||||
}
|
||||
|
||||
protected void Rebuild() {
|
||||
Profiler.BeginSample("UI Tree Build");
|
||||
VisualElement child = Build();
|
||||
Profiler.EndSample();
|
||||
|
||||
m_Document.rootVisualElement.Q<VisualElement>("root__container").Clear();
|
||||
m_Document.rootVisualElement.Q<VisualElement>("root__container").Add(child);
|
||||
}
|
||||
|
||||
public abstract VisualElement Build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user