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

@@ -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);