//异步加载场景
using UnityEngine;
using System.Collections;using UnityEngine.SceneManagement;
public class JumpScene : MonoBehaviour {
void Start()
{
//当前场景名字
if (SceneManager.GetActiveScene().name == "StartSceneName"){
//跳转场景名字
StartCoroutine(Loading("GameSceneName"));}
}
public IEnumerator Loading(string scenceName)
{
float f = 0;
float time = 2f;
AsyncOperation asy = Application.LoadLevelAsync(scenceName);
asy.allowSceneActivation = false;
//两秒后跳转
while (f <= time){
f += Time.deltaTime;
yield return new WaitForEndOfFrame();
}
asy.allowSceneActivation = true;
}
//重新加载场景
SceneManager.LoadScene(SceneManager.GetActiveScene().name); //获取当前场景的名字,然后跳转