Using application to realize the switching of scenes

Source: Internet
Author: User

Create a new 3 scene, create a new GUI Text, set different values to differentiate

File->build settings, drag three scenes (scenes in build) to see the scene name and scene index.
As long as the tick is selected, these scenes will appear when released into the finished product.

Then write the script to switch

Using unityengine;using System.collections;public class newbehaviourscript:monobehaviour{//Use this for Initializat ion void Start () {}//Update is called once per frame void Update () {if (Input.getkeydown (KEYC Ode.          A) {//load scene, can use scene name or scene index Application.loadlevel (0);        } if (Input.getkeydown (keycode.b)) {application.loadlevel (1);        } if (Input.getkeydown (keycode.c)) {application.loadlevel (2); } if (Input.getkeydown (keycode.space)) {//press SPACEBAR to truncate the current scene into a 1.png picture APPLICATION.CAPTURESCR        Eenshot (@ "C:\Users\Administrator\Desktop\1.png"); } if (Input.getkeydown (KEYCODE.D)) {//Opens a URL with the default browser Application.openurl ("http://www.ba        Idu.com ");        } if (Input.getkeydown (Keycode.escape)) {//Exit program Application.Quit (); }    }}
Drag the script to each scene, because each scene executes the script: double-click Scene > Camera---give the script to the camera

If you want to see Quit (), the effect will be more obvious if you publish it as a finished product.

File->build Settings->build and run


Using application to realize the switching of scenes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.