This commit is contained in:
CortexCore
2024-07-15 17:26:08 +08:00
parent de0bae347d
commit e686eb89ab
4 changed files with 74 additions and 45 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UIElements;
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable ClassWithVirtualMembersNeverInherited.Global
@@ -31,6 +32,9 @@ namespace BITKit.UX
[Header(Constant.Header.Components)]
[SerializeField] protected UIDocument document;
[Header(Constant.Header.Settings)]
[SerializeField, ReadOnly] private bool isActive;
[SerializeField,ReadOnly] private float currentOpacity;
[Header(Constant.Header.Settings)]
[SerializeField] private bool isWindow;
[SerializeField] private bool isAnimate;
@@ -57,14 +61,14 @@ namespace BITKit.UX
protected virtual VisualElement background => document.rootVisualElement;
protected float CurrentOpacity
{
get => background?.GetOpacity() ?? _currentOpacity;
get => background?.GetOpacity() ?? currentOpacity;
set
{
_currentOpacity = value;
currentOpacity = value;
background?.SetOpacity(value);
}
}
private float _currentOpacity;
protected virtual void Awake()
{
cancellationToken = gameObject.GetCancellationTokenOnDestroy();
@@ -121,6 +125,7 @@ namespace BITKit.UX
Debug.Log(gameObject.name);
throw;
}
isActive = true;
}
async UniTask IEntryElement.EntryAsync()
{
@@ -156,6 +161,7 @@ namespace BITKit.UX
void IEntryElement.Exited()
{
document.rootVisualElement.SetActive(false);
isActive = false;
}
public event Action OnEntry;