当前位置:网站首页>Unity scene jump and exit
Unity scene jump and exit
2022-07-06 12:33:00 【SQ Liu】
brief introduction :
Unity Realize simple jump of each scene in , And click “ Exit scene ” Close the interface .
Realization effect :
Implementation steps :
One 、 New scene
In the project you created , Add several scenarios that need to jump , Here we use 4 Take the jump between scenes as an example .4 The scene names are shown in the following figure .
In the scene above , You can first create a corresponding scene name 3D object , for example , scene Capsule in , You can create several capsules Capsule( As shown in the figure below ); scene Cube in , You can create several cubes Cube; scene Sphere in , You can create several spheres Sphere. What specific scenarios are created , According to your respective projects , And the scene that needs to complete the jump , Here is just a case .
Two 、 Create jump button
1、 As shown in the figure below , establish UI-Button.
2、 Modify canvas Canvas Of UI Scale Mode And its resolution .
3、 modify Button name , See the name and know the meaning , Prevent confusion caused by adding other buttons later , The specific operation is shown in the figure below .
4、Ctrl+D Copy 4 Share , Rename their buttons to BtnCube,BtnMain,BtnSphere,BtnTuiChu, And adjust their position in the canvas , As shown in the figure below .
3、 ... and 、 Add code
1、 Create a new one called “Scripts” Folder , Used to store all C# Script .
2、 All jump codes are as follows :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ChangJingTiaoZhuan : MonoBehaviour
{
public void TiaoZhuanCapsule()
{
SceneManager.LoadScene("Capsule");
}
public void TiaoZhuanCube()
{
SceneManager.LoadScene("Cube");
}
public void TiaoZhuanMain()
{
SceneManager.LoadScene("Main");
}
public void TiaoZhuanSphere()
{
SceneManager.LoadScene("Sphere");
}
public void TuiChuChangJing()
{
//#if UNITY_EDITOR
//UnityEditor.EditorApplication.isPlaying = false;// Exit in editing state
//#else
Application.Quit();// Package and compile and exit
//#endif
}
}
Four 、 Add button event registration
1、 Drag the script to Canvas in , As shown in the figure below .
2、 The specific operation is shown in the figure below .
3、 The reason for adding the following buttons to respond to events is the same as above , Be careful not to add dislocation to the corresponding event .
4、 When all are added , Save the current scene .
5、 Mouse selected Canvas and EventSystem, Right click and select Copy Copy, As shown in the figure below .
6、 Double click the mouse to enter the scene Cube, Then paste Paste In the previous scene Canvas.
7、 additional Main Scene and Sphere The scene operation steps are the same .
8、 Click on File, choice Build Settings, Drag in all the scenes that need to jump , As shown in the figure below .
notes : This step must have , Otherwise, the scene to jump will not be found after running !!
9、 thus , Jump switching between different scenes , And the exit scenario operation is completed .
5、 ... and 、 Engineering release
1、 Click on File, choice Build Settings, choice Player Settings, Modify some of its properties , Click when finished “Build” that will do .
2、Build After completion , Open its folder , Double-click to open “TiaoZhuan.exe” The program is ready to run .
边栏推荐
- Talking about the startup of Oracle Database
- Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
- Esp8266 connects to bafayun (TCP maker cloud) through Arduino IED
- .elf .map .list .hex文件
- Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
- idea问题记录
- Compilation principle: preprocessing of source program and design and implementation of lexical analysis program (including code)
- Latex learning
- Single chip Bluetooth wireless burning
- Arm pc=pc+8 is the most understandable explanation
猜你喜欢
Unity场景跳转及退出
Amba, ahb, APB, Axi Understanding
MySQL時間、時區、自動填充0的問題
(5) Introduction to R language bioinformatics -- ORF and sequence analysis
Programmers can make mistakes. Basic pointers and arrays of C language
(三)R语言的生物信息学入门——Function, data.frame, 简单DNA读取与分析
idea问题记录
Mp3mini playback module Arduino < dfrobotdfplayermini H> function explanation
Esp8266 connect onenet (old mqtt mode)
Kconfig Kbuild
随机推荐
Intermediate use tutorial of postman [environment variables, test scripts, assertions, interface documents, etc.]
js 变量作用域和函数的学习笔记
Common DOS commands
Understanding of AMBA, AHB, APB and Axi
Esp8266 uses Arduino to connect Alibaba cloud Internet of things
ESP learning problem record
js题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。
Gateway 根据服务名路由失败,报错 Service Unavailable, status=503
Gravure sans fil Bluetooth sur micro - ordinateur à puce unique
Knowledge summary of request
1081 rational sum (20 points) points add up to total points
Amba, ahb, APB, Axi Understanding
[offer78]合并多个有序链表
2021.11.10汇编考试
1041 Be Unique (20 point(s))(哈希:找第一个出现一次的数)
Easy to use shortcut keys in idea
Learning notes of JS variable scope and function
[Clickhouse kernel principle graphic explanation] about the collaborative work of partitioning, indexing, marking and compressed data
Vulnhub target: hacknos_ PLAYER V1.1
ORA-02030: can only select from fixed tables/views