1
This commit is contained in:
49
unity/Assets/Script/Managers/SenceManager.cs
Normal file
49
unity/Assets/Script/Managers/SenceManager.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Manager
|
||||
{
|
||||
class SenceManager:MonoSingleton<SenceManager>
|
||||
{
|
||||
UnityAction<float> onProgress = null;
|
||||
|
||||
public void LoadScene(int name)
|
||||
{
|
||||
StartCoroutine(LoadLevel(name));
|
||||
|
||||
}
|
||||
|
||||
IEnumerator LoadLevel( int id)
|
||||
{
|
||||
Debug.LogFormat("LoadLevel: {0}", name);
|
||||
AsyncOperation async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(id);
|
||||
|
||||
async.allowSceneActivation = true;
|
||||
async.completed += LevelLoadCompleted;
|
||||
|
||||
//保存数据
|
||||
PlayerInfo.Instance.info.currentMap=id;
|
||||
SaveSystem.SaveDate(PlayerInfo.Instance.info.DatePath, PlayerInfo.Instance.info);
|
||||
|
||||
while (!async.isDone)
|
||||
{
|
||||
if (onProgress != null)
|
||||
onProgress(async.progress);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void LevelLoadCompleted(AsyncOperation obj)
|
||||
{
|
||||
if (onProgress != null)
|
||||
onProgress(1f);
|
||||
Debug.Log("LevelLoadCompleted:" + obj.progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user