2025-01-02 12:15:45 +08:00
|
|
|
|
using CG.Framework;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
*Create By CG
|
|
|
|
|
|
*Function <EFBFBD>첽<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ)
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
namespace CG.UTility
|
|
|
|
|
|
{
|
2025-04-01 16:16:45 +08:00
|
|
|
|
public class LoadScenesAsyncNoPanel : MonoSingleton<LoadScenesAsyncNoPanel>
|
2025-01-02 12:15:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
private bool _isLoadScene;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD>
|
|
|
|
|
|
private AsyncOperation _async;
|
|
|
|
|
|
private int _toProgress = 0;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private int _nowProgress = 0;//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
private System.Action _loadedCall = null;
|
2025-04-01 16:16:45 +08:00
|
|
|
|
public GameObject eventsystem;
|
2025-01-02 12:15:45 +08:00
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_isLoadScene)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_async == null) return;
|
|
|
|
|
|
if (_async.progress < 0.9f)
|
|
|
|
|
|
{
|
|
|
|
|
|
_toProgress = (int)_async.progress * 100;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_toProgress = 100;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (_nowProgress < _toProgress)
|
|
|
|
|
|
{
|
|
|
|
|
|
_nowProgress++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_nowProgress == 100)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_async.isDone)
|
|
|
|
|
|
{
|
|
|
|
|
|
_loadedCall?.Invoke();
|
|
|
|
|
|
_isLoadScene = false;
|
|
|
|
|
|
StopCoroutine("LoadScene");
|
2025-04-02 14:37:35 +08:00
|
|
|
|
UIRoot.Instance.GetEventSystem().gameObject.SetActive(true);
|
2025-01-02 12:15:45 +08:00
|
|
|
|
Framework.UI_Manage.Instance.ClosePanel("LoadingSceenPanel");
|
|
|
|
|
|
}
|
|
|
|
|
|
_async.allowSceneActivation = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sceneName"></param>
|
|
|
|
|
|
public void LoadSceneAsync(string sceneName, System.Action LoadedCall)
|
|
|
|
|
|
{
|
|
|
|
|
|
_loadedCall = LoadedCall;
|
|
|
|
|
|
_toProgress = 0;
|
|
|
|
|
|
_nowProgress = 0;
|
|
|
|
|
|
_isLoadScene = true;
|
|
|
|
|
|
StartCoroutine("LoadScene", sceneName);
|
|
|
|
|
|
Framework.UI_Manage.Instance.ShowPanel("LoadingSceenPanel", System.Type.GetType("CG.Framework.LoadingSceenPanel"), Framework.UIGroup.Tip);
|
2025-04-02 14:37:35 +08:00
|
|
|
|
UIRoot.Instance.GetEventSystem().gameObject.SetActive(false);
|
2025-01-02 12:15:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerator LoadScene(string sceneName)
|
|
|
|
|
|
{
|
|
|
|
|
|
_async = SceneManager.LoadSceneAsync(sceneName);
|
|
|
|
|
|
_async.allowSceneActivation = false;
|
|
|
|
|
|
yield return new WaitForEndOfFrame();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
|
yield return _async;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|