using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
public class SceneLoader : SingleMonoBehaviour<SceneLoader>
{
public UnityAction unityAction;
public void LoadSplashScene (bool needLoadingUI = true)
{
StartCoroutine (Load ("SplashScreen", needLoadingUI));
}
public void LoadStartUpScene (bool needLoadingUI = true)
{
StartCoroutine (Load ("StartUp", needLoadingUI));
}
public void LoadGameScene (bool needLoadingUI = true)
{
StartCoroutine (Load ("Game", needLoadingUI));
}
private IEnumerator Load (string scene, bool needLoadingUI)
{
Clean ();
if (needLoadingUI)
{
//longLoadingMediator.Show ();
}
AsyncOperation asyncOperation = SceneManager.LoadSceneAsync (scene);
while (!asyncOperation.isDone)
{
yield return null;
}
if (unityAction != null)
{
unityAction ();
}
}
private void Clean ()
{
Resources.UnloadUnusedAssets ();
GC.Collect ();
}
}
场景加载器
最新推荐文章于 2018-03-28 10:12:46 发布