70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
using UnityEngine.InputSystem;
|
|
using BITKit;
|
|
using BITKit.UX;
|
|
using BITKit.Entities;
|
|
using BITKit.SceneManagement;
|
|
|
|
namespace BITFALL.UX
|
|
{
|
|
public class UXLoading : UIToolKitPanel
|
|
{
|
|
[Header(Constant.Header.Providers)]
|
|
[SerializeReference, SubclassSelector] private ISceneService sceneService;
|
|
[SerializeReference, SubclassSelector] private INetProvider netProvider;
|
|
[Header(Constant.Header.Components)]
|
|
[SerializeField] private UXBar loadBar;
|
|
[SerializeField] private UXLabel loadText;
|
|
[SerializeField] private UXLabel mapLabel;
|
|
[SerializeField] private UXElement blackScreen;
|
|
protected override VisualElement background => null;
|
|
|
|
[Inject]
|
|
private IUXWaiting _waiting;
|
|
private IUXWaitingHandle _waitingHandle;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
sceneService.OnLoadScene += Load;
|
|
sceneService.OnSceneLoadProgress += OnLoadProgress;
|
|
|
|
sceneService.OnUnloadScene += OnUnloadScene;
|
|
sceneService.OnSceneUnloaded += OnSceneUnloaded;
|
|
}
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
DI.Inject(this);
|
|
}
|
|
|
|
private void Load(string obj)
|
|
{
|
|
mapLabel.Set(obj);
|
|
loadBar.SetDirect(0,$"正在开始加载:{obj}");
|
|
Entry();
|
|
}
|
|
private void OnLoadProgress(string s, float f)
|
|
{
|
|
loadBar.Set(f);
|
|
loadText.Set(s);
|
|
}
|
|
private void OnSceneUnloaded(string obj)
|
|
{
|
|
if (_waitingHandle is not null)
|
|
{
|
|
_waiting.Release(_waitingHandle);
|
|
}
|
|
}
|
|
private void OnUnloadScene(string obj)
|
|
{
|
|
if(_waiting is null)return;
|
|
_waitingHandle = _waiting.Get();
|
|
_waitingHandle.SetMessage("正在返回主场景");
|
|
}
|
|
}
|
|
} |