This commit is contained in:
parent
de0bae347d
commit
e686eb89ab
|
@ -53,6 +53,7 @@ namespace BITKit.Entities
|
|||
/// </summary>
|
||||
public interface IEntitiesService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 当添加Entity时
|
||||
/// </summary>
|
||||
|
|
|
@ -53,10 +53,14 @@ namespace BITKit
|
|||
[SerializeField] private bool isOffline;
|
||||
[SerializeField] private bool IsEditorSimulateMode;
|
||||
|
||||
[UXBindPath("progress-bar")]
|
||||
[UXBindPath("progress-bar",true)]
|
||||
private ProgressBar _progressBar;
|
||||
[UXBindPath("progress-fill",true)]
|
||||
private VisualElement _progressFill;
|
||||
[UXBindPath("progress-label")]
|
||||
private Label _progressLabel;
|
||||
|
||||
private Action<float> _setProgressValue;
|
||||
private async void Start()
|
||||
{
|
||||
try
|
||||
|
@ -67,7 +71,16 @@ namespace BITKit
|
|||
#endif
|
||||
UXUtils.Inject(this);
|
||||
|
||||
_progressBar.value=0f;
|
||||
if (_progressBar is not null)
|
||||
{
|
||||
_setProgressValue = value => _progressBar.value = value;
|
||||
}else if (_progressFill is not null)
|
||||
{
|
||||
_setProgressValue = value =>
|
||||
_progressFill.style.width = new Length() { value = value*100, unit = LengthUnit.Percent };
|
||||
}
|
||||
|
||||
_setProgressValue?.Invoke(0f);
|
||||
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
@ -127,7 +140,8 @@ namespace BITKit
|
|||
while (initOperation.IsDone is false)
|
||||
{
|
||||
await UniTask.NextFrame(destroyCancellationToken);
|
||||
_progressBar.value =initOperation.Progress;
|
||||
//_progressBar.value =initOperation.Progress;
|
||||
_setProgressValue?.Invoke(initOperation.Progress);
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -137,7 +151,8 @@ namespace BITKit
|
|||
while (operation.IsDone is false)
|
||||
{
|
||||
await UniTask.NextFrame(destroyCancellationToken);
|
||||
_progressBar.value = operation.Progress;
|
||||
//_progressBar.value = operation.Progress;
|
||||
_setProgressValue?.Invoke(operation.Progress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,7 +182,8 @@ namespace BITKit
|
|||
while (frameworkHandle.IsDone is false)
|
||||
{
|
||||
await UniTask.NextFrame(destroyCancellationToken);
|
||||
_progressBar.value=frameworkHandle.Progress;
|
||||
//_progressBar.value=frameworkHandle.Progress;
|
||||
_setProgressValue?.Invoke(frameworkHandle.Progress);
|
||||
}
|
||||
|
||||
var framework = Instantiate(frameworkHandle.AssetObject);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -121,48 +121,54 @@ namespace BITKit.UX
|
|||
}
|
||||
private void Update()
|
||||
{
|
||||
while (RegistryQueue.TryDequeue(out var result))
|
||||
try
|
||||
{
|
||||
if (result is null) continue;
|
||||
EntryGroup.list.Add(result);
|
||||
Panels.Set(result.Index, result);
|
||||
}
|
||||
|
||||
while (UnRegistryQueue.TryDequeue(out var result))
|
||||
{
|
||||
if (result is null) continue;
|
||||
EntryGroup.list.Remove(result);
|
||||
Panels.Remove(result.Index);
|
||||
}
|
||||
|
||||
if (ReturnBuffer.TryGetRelease(out var returnPanel))
|
||||
{
|
||||
EntryGroup.Entry(x=>x.Index==returnPanel.Index);
|
||||
BITAppForUnity.AllowCursor.SetElements(this, returnPanel.AllowCursor);
|
||||
BITInputSystem.AllowInput.SetElements(this, returnPanel.AllowInput);
|
||||
}
|
||||
|
||||
if (EntryQueue.TryPop(out var nextPanel))
|
||||
{
|
||||
if (nextPanel.IsWindow)
|
||||
while (RegistryQueue.TryDequeue(out var result))
|
||||
{
|
||||
WindowEntryGruop.Entry(nextPanel);
|
||||
return;
|
||||
if (result is null) continue;
|
||||
EntryGroup.list.Add(result);
|
||||
Panels.Set(result.Index, result);
|
||||
}
|
||||
|
||||
while (UnRegistryQueue.TryDequeue(out var result))
|
||||
{
|
||||
if (result is null) continue;
|
||||
EntryGroup.list.Remove(result);
|
||||
Panels.Remove(result.Index);
|
||||
}
|
||||
WindowEntryGruop.Entry(-1);
|
||||
History.Push(CurrentPanel);
|
||||
EntryGroup.Entry(x=>x.Index==nextPanel.Index);
|
||||
BITAppForUnity.AllowCursor.SetElements(this, nextPanel.AllowCursor);
|
||||
BITInputSystem.AllowInput.SetElements(this, nextPanel.AllowInput);
|
||||
}
|
||||
|
||||
if (EntryGroup.TryGetEntried(out var currentPanel))
|
||||
if (ReturnBuffer.TryGetRelease(out var returnPanel))
|
||||
{
|
||||
EntryGroup.Entry(x=>x.Index==returnPanel.Index);
|
||||
BITAppForUnity.AllowCursor.SetElements(this, returnPanel.AllowCursor);
|
||||
BITInputSystem.AllowInput.SetElements(this, returnPanel.AllowInput);
|
||||
}
|
||||
|
||||
if (EntryQueue.TryPop(out var nextPanel))
|
||||
{
|
||||
if (nextPanel.IsWindow)
|
||||
{
|
||||
WindowEntryGruop.Entry(nextPanel);
|
||||
return;
|
||||
}
|
||||
WindowEntryGruop.Entry(-1);
|
||||
History.Push(CurrentPanel);
|
||||
EntryGroup.Entry(x=>x.Index==nextPanel.Index);
|
||||
BITAppForUnity.AllowCursor.SetElements(this, nextPanel.AllowCursor);
|
||||
BITInputSystem.AllowInput.SetElements(this, nextPanel.AllowInput);
|
||||
}
|
||||
if (EntryGroup.TryGetEntried(out var currentPanel))
|
||||
{
|
||||
currentPanel.OnUpdate(Time.deltaTime);
|
||||
};
|
||||
if(WindowEntryGruop.TryGetEntried(out var windowPanel))
|
||||
{
|
||||
windowPanel.OnUpdate(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
currentPanel.OnUpdate(Time.deltaTime);
|
||||
};
|
||||
if(WindowEntryGruop.TryGetEntried(out var windowPanel))
|
||||
{
|
||||
windowPanel.OnUpdate(Time.deltaTime);
|
||||
BIT4Log.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue