SceneManager.LoadScene的使用方法
来源:互联网 发布:unturned汉化mac 编辑:程序博客网 时间:2024/06/07 19:31
using UnityEngine;
[AddComponentMenu("MyGame/TitleSceen")]
public class TitleSceen : MonoBehaviour {
void OnGUI(){
//文字大小
GUI.skin.label.fontSize = 48;
//UI中心对齐 TextAnchor.LowerCenter指的是在Label矩形框内的位置
GUI.skin.label.alignment = TextAnchor.LowerCenter;
//显示标题
GUI.Label(new Rect(0,30,Screen.width,150),"太空大战");
//开始游戏按钮
if (GUI.Button (new Rect (Screen.width * 0.5f - 100, Screen.height * 0.7f, 200, 30), "开始游戏")) {
//开始读取下一关LoadLevel在新版本中被废除了
}
}
using System.Collections;
//SceneManager.LoadScene方法所在的类必须要添加后才可使用
using UnityEngine.SceneManagement;[AddComponentMenu("MyGame/TitleSceen")]
public class TitleSceen : MonoBehaviour {
void OnGUI(){
//文字大小
GUI.skin.label.fontSize = 48;
//UI中心对齐 TextAnchor.LowerCenter指的是在Label矩形框内的位置
GUI.skin.label.alignment = TextAnchor.LowerCenter;
//显示标题
GUI.Label(new Rect(0,30,Screen.width,150),"太空大战");
//开始游戏按钮
if (GUI.Button (new Rect (Screen.width * 0.5f - 100, Screen.height * 0.7f, 200, 30), "开始游戏")) {
//开始读取下一关LoadLevel在新版本中被废除了
//Application.LoadLevel(1);
//在5.0版unity中应用SceneManager.LoadScene来取代
SceneManager.LoadScene("SpaceWar");}
}
}
SceneManager.LoadScene
public static void LoadScene(int sceneBuildIndex, SceneManagement.LoadSceneMode mode = LoadSceneMode.Single);public static void LoadScene(string sceneName, SceneManagement.LoadSceneMode mode = LoadSceneMode.Single);
Parameters
sceneNameName of the scene to load.sceneBuildIndexIndex of the scene in the Build Settings to load.modeAllows you to specify whether or not to load the scene additively. See LoadSceneMode for more information about the options.Description
Loads the scene by its name or index in Build Settings.
The given sceneName can either be the last part of the path, without .unity extension or the full path still without the .unity extension. The path has to be exactly as shown in the Build Settings Window. If only the scene name is given this will load the first scene in the list that matches. If you have multiple scenes with same name but different paths, you should use the full path.
2 0
- SceneManager.LoadScene的使用方法
- SceneManager.LoadScene
- unity 最新场景加载SceneManager.LoadScene的用法
- 问题十:关于application.loadlevel和SceneManager.LoadScene调用后新场景会变暗的问题
- u3d SceneManager.LoadScene("main") 场景变黑解决
- Ogre的SceneManager分析
- Ogre的SceneManager分析
- Ogre的SceneManager分析
- SceneManager里的几个事件相关函数
- Unity实战笔记_6.简单的UI框架SceneManager
- TinyRenderEngine------SceneManager
- OGRE基础教程一:OGRE最基本的组成结构:SceneManager,SceneNode和Entity objects
- Ogre中SceneManager分析
- Ogre中SceneManager分析
- Ogre中SceneManager分析
- Ogre 1.8 SceneManager
- ogre 场景管理器 scenemanager
- SceneManager替换Application.LoadLevel
- Android微信SDK API 调用教程
- LeetCode 之 Container With Most Water
- Android studio 调用Assets中的xml文件
- Tomcat配置Basic Authentication
- javamail 通过163邮箱发送邮件
- SceneManager.LoadScene的使用方法
- Cookie与Session的区别-总结很好的文章
- Java WebService 简单实例
- scala中的option[T]、Any、Nothing、Null和Nil
- 仿存储过程的令一种方式
- MT6735平台LCM调试
- CSS选择器——了解选择器的用法
- Windows下根据源代码编译py module时遇到的若干问题
- <input>标签常见用法