更改了文件结构
This commit is contained in:
78
Src/Unity/Scripts/UX/Service/UI Toolkit/UIToolKitPanel.cs
Normal file
78
Src/Unity/Scripts/UX/Service/UI Toolkit/UIToolKitPanel.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
// ReSharper disable MemberCanBeProtected.Global
|
||||
// ReSharper disable ClassWithVirtualMembersNeverInherited.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class UIToolKitPanel : MonoBehaviour,IUXPanel
|
||||
{
|
||||
public UIToolKitPanel()
|
||||
{
|
||||
Index = GetType().FullName;
|
||||
}
|
||||
[Header(Constant.Header.Components)]
|
||||
[SerializeField] protected UIDocument document;
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private bool isAnimate;
|
||||
[SerializeField] private bool allowCursor;
|
||||
[SerializeField] private bool allowInput;
|
||||
[SerializeField] private bool autoEntry;
|
||||
public bool IsAnimate => isAnimate;
|
||||
public bool IsValid => cancellationToken.IsCancellationRequested is false;
|
||||
public string Index { get; private set; }
|
||||
public bool AllowCursor => allowCursor;
|
||||
public bool AllowInput => allowInput;
|
||||
protected CancellationToken cancellationToken { get; private set; }
|
||||
protected virtual void Awake()
|
||||
{
|
||||
cancellationToken = gameObject.GetCancellationTokenOnDestroy();
|
||||
Index= typeof(UIToolKitPanel) == GetType() ? gameObject.name : GetType().Name;
|
||||
}
|
||||
protected virtual void Start()
|
||||
{
|
||||
if(IsValid && autoEntry)
|
||||
UXService.Entry(this);
|
||||
}
|
||||
public void Entry()
|
||||
{
|
||||
UXService.Entry(this);
|
||||
}
|
||||
protected virtual void OnEnable()=>UXService.Register(this);
|
||||
protected virtual void OnDisable()=>UXService.UnRegister(this);
|
||||
void IUXPanel.Entry()
|
||||
{
|
||||
OnEntryOrExit(true);
|
||||
document.rootVisualElement.SetActive(true);
|
||||
OnEntry?.Invoke();
|
||||
}
|
||||
void IUXPanel.Exit()
|
||||
{
|
||||
if (IsValid is false) return;
|
||||
OnEntryOrExit(false);
|
||||
try
|
||||
{
|
||||
document.rootVisualElement.SetActive(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.Warning<UIToolKitPanel>(name);
|
||||
BIT4Log.LogException(e);
|
||||
}
|
||||
OnExit?.Invoke();
|
||||
}
|
||||
public event Action OnEntry;
|
||||
public event Action OnExit;
|
||||
|
||||
protected virtual void OnEntryOrExit(bool isEntry)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9df4ccf721aaec45a7fadfead86ec48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user