Unity5 新api:Scenemanager场景切换

using UnityEngine;
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");
}
}
}
时间: 2024-08-04 00:22:26

Unity5 新api:Scenemanager场景切换的相关文章

Unity3D_(API)场景切换SceneManager

Unity场景切换SceneManager 官方文档:传送门 静态方法 创建场景 CreateScene Create an empty new Scene at runtime with the given name. 得到当前激活的场景 GetActiveScene Gets the currently active Scene. 根据index得到一个场景 GetSceneAt Get the Scene at index in the SceneManager's list of loa

UGUI_游戏菜单场景切换

事件委托 GameManger(空物体)+GameManger脚本--重要的方式 public class GameManger : MonoBehaviour { public void OnStartGame(string sceneName) { Application.LoadLevel(sceneName); } } using System.Collections; using System.Collections.Generic; using UnityEngine; using

Unity 中场景切换

Unity游戏开发中,单个Scene解决所有问题似乎不可能,那么多个Scene之间的切换是必然存在.如果仅仅是切换,似乎什么都好说,但是在场景比较大的时候不想让玩家等待加载或者说场景与场景之间想通过一些画面.动画表现出一些让玩家期待的东西,大家就要去认真考虑.这篇文章主要介绍两种增加切换中如何播放画面或者动画等等,提高玩家的浸入感,当然你也可以做成无缝的场景. 1 操作基础函数 LoadLevel Loads the level by its name or index.  加载场景,加载之前你

cocos2d-x 场景切换

***************************************转载请注明出处:http://blog.csdn.net/lttree******************************************* 今天终于把界面交上去了,~~o(>_<)o ~~,花费了好多时间... 做个  场景切换  来庆祝一下. PS:欢迎大家一起讨论呀~,共同加油! ********************************* 本文三部分: 1.前言 2.菜单按钮执行场景切换

Egret场景切换管理类切换和单例使用方法

场景切换是很多开发者在开发过程中必不可少的一个环节,当项目中有两个或两个以上的游戏场景时,怎样管理这些场景,能够使它们之间的切换更加方便呢?今天就为大家介绍场景切换管理类的切换方法和单例的使用方法. 案例源码:https://github.com/hkjlx/qhcj 首先创建一个所有场景的父类Scene Scene类主要是为了方便管理场景,此类是一个抽象类,子类必须继承此类并实现onComplete()抽象方法才能进行场景的切换. abstract class Scene extends eu

8 cocos2dx添加场景切换效果,控制场景切换彻底完成之后再执行动画

 1 添加场景切换效果 供场景切换的类: CCTransitionJumpZoom CCTransitionProgressRadialCCW CCTransitionProgressRadialCW CCTransitionProgressHorizontal CCTransitionProgressVertical CCTransitionProgressInOut CCTransitionProgressOutIn CCTransitionCrossFade CCTransitionF

cocos2dx 场景切换

版本是 cocos2dx 3.3 场景切换的时刻是:(代码有删减) void Director::drawScene() { // calculate "global" dt calculateDeltaTime(); if (_nextScene) { setNextScene(); } } 每一帧都会检查,看是不是有 _nextScene, 也就是 是不是需要进行场景切换了. 一般场景切换的过程: 当添加一个场景时,正在运行的场景会调用 _runningScene->onEx

Cocos2d-X3.0 刨根问底(九)----- 场景切换(TransitionScene)源代码分析

上一章我们分析了Scene与Layer相关类的源代码,对Cocos2d-x的场景有了初步了解,这章我们来分析一下场景变换TransitionScene源代码. 直接看TransitionScene的定义 class CC_DLL TransitionScene : public Scene { public: /** Orientation Type used by some transitions */ enum class Orientation { /// An horizontal or

Cocos2d-X3.0 刨根问底(九)----- 场景切换(TransitionScene)源码分析

上一章我们分析了Scene与Layer相关类的源码,对Cocos2d-x的场景有了初步了解,这章我们来分析一下场景变换TransitionScene源码. 直接看TransitionScene的定义 class CC_DLL TransitionScene : public Scene { public: /** Orientation Type used by some transitions */ enum class Orientation { /// An horizontal orie