【 unity3d 】跳转场景

一:设置场景


把需要的场景跳转和使用的场景拖上去


二:脚本代码

1、旧版本unity使用Application.LoadLevel()方法,里面传入场景名,或者标签号

标签号查看方式


2、代码展示,这里使用按钮点击调用该方法

using UnityEngine;
using System.Collections;

public class LoadScenesSC : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnClick(){
		//场景跳转...
		//Application.LoadLevel("demo3NewScenes");//参数跳转场景的下标
		Application.LoadLevel (1);
	}

}

3、untiy新版本加载场景

需要引入命名空间

using UnityEngine.SceneManagement;//新版本跳转函数需要引进空间名
SceneManager.LoadScene()

三:加载后对场景进行烘焙

场景加载后,会出现灰暗没有颜色的情况,此时要对哪个跳转创建进行烘焙。

 

把Auto的勾取消,然后点击Build,此时会创建该场景的烘焙文件

 


猜你喜欢

转载自blog.csdn.net/liaoshengg/article/details/80856613