BITFALL/Assets/Artists/Scripts/UX/UXLoading.cs

42 lines
1.1 KiB
C#
Raw Normal View History

2023-08-23 01:59:40 +08:00
using System;
2023-06-08 14:09:50 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.InputSystem;
using BITKit;
using BITKit.UX;
using BITKit.Entities;
2023-10-20 19:31:12 +08:00
using BITKit.SceneManagement;
2023-06-08 14:09:50 +08:00
namespace BITFALL.UX
{
2023-10-20 19:31:12 +08:00
public class UXLoading : UIToolKitPanel
2023-06-08 14:09:50 +08:00
{
2023-06-17 16:30:53 +08:00
[Header(Constant.Header.Providers)]
2023-10-20 19:31:12 +08:00
[SerializeReference,SubclassSelector] private ISceneService sceneService;
2023-08-27 02:58:19 +08:00
[SerializeReference, SubclassSelector]
2023-06-17 16:30:53 +08:00
private INetProvider netProvider;
[Header(Constant.Header.Components)]
2023-06-08 14:09:50 +08:00
public UXBar loadBar;
public UXLabel loadText;
2023-08-23 01:59:40 +08:00
protected override void Awake()
2023-06-08 14:09:50 +08:00
{
2023-08-23 01:59:40 +08:00
base.Awake();
2023-10-20 19:31:12 +08:00
sceneService.OnLoadScene += Load;
sceneService.OnSceneLoadProgress += OnLoadProgress;
2023-08-23 01:59:40 +08:00
}
2023-08-12 01:43:24 +08:00
2023-10-20 19:31:12 +08:00
private void Load(string obj)
2023-06-08 14:09:50 +08:00
{
2023-10-20 19:31:12 +08:00
loadBar.SetDirect(0,$"正在开始加载:{obj}");
2023-08-23 01:59:40 +08:00
Entry();
2023-06-08 14:09:50 +08:00
}
2023-10-20 19:31:12 +08:00
private void OnLoadProgress(string s, float f)
2023-06-08 14:09:50 +08:00
{
2023-10-20 19:31:12 +08:00
loadBar.Set(f);
loadText.Set(s);
2023-06-08 14:09:50 +08:00
}
}
}