Exquisite Cup unity development experience--Start menu GUI production

Source: Internet
Author: User

2015/08/04//////////////

by xbw/////////////////////

Environment Unity 4.6//////////


Check it out first.

That's good,,,

to code

Using unityengine;using System.Collections;    [Requirecomponent (typeof (Audiosource))]public class Mainmenugui:monobehaviour {public AudioClip beep;    Public Guiskin Menuskin;    Public Rect menuarea;    Public Rect PlayButton;    Public Rect Instructionsbutton;    Public Rect Quitbutton;    Public Rect Playwaysbutton;    public Rect instructions;    Public Rect Highscoresbutton;    Public texture2d img;    Rect menuareanormalized; String menupage = "main";//use of this for Initializationvoid Start () {menuareanormalized = new Rect uarea.x * Screen.width-(Menuarea.width * 0.3f), MENUAREA.Y * screen.height-(Menuarea.height * 0.3f), Menuarea.width, M       Enuarea.height);    menuareanormalized =//New Rect (Screen.width, screen.height);}        void Ongui () {Guistyle backGround = new Guistyle ();        BackGround.normal.background = img; Gui.        Label (New Rect (0, 0, Screen.width, screen.height), "", BackGround); Gui.skin = mEnuskin; Gui.        BeginGroup (menuareanormalized); if (Menupage = = "Main") {if (GUI.                button (new Rect (PlayButton), "test Mode")) {//startcoroutine ("buttonaction", "second");                Application.loadlevel ("second"); Audio.                Playoneshot (beep);            Menupage = "Test"; } if (GUI. button (new Rect (Highscoresbutton), "Cool run Mode")) {//audio.                Playoneshot (beep);            Startcoroutine ("Buttonaction", "Loading4"); } if (GUI. button (new Rect (Instructionsbutton), "Introduction Note")) {audio.                Playoneshot (beep);            Menupage = "Instructions"; }//if (GUI. button (new Rect (Playwaysbutton), "Playways"))//{//audio.             Playoneshot (beep);           Menupage = "Playways"; } if (GUI. button (new Rect (Quitbutton), "Exit Game")) {Startcoroutine ("Buttonaction "," Quit "); }} else if (menupage== "instructions") {GUI.            Label (new Rect (instructions), "Linglong Tire test mode (truck, sports car, parking entry test, direction key control), Linglong Parkour mode (collect four exquisite tires, space/touch, move around by collision)"); if (GUI. button (new Rect (Quitbutton), "back")) {audio.                Playoneshot (beep);            Menupage = "main"; }} else if (Menupage = = "Instructionsa") {GUI.            Label (new Rect (instructions), "Unlocked, select cool run mode"); if (GUI. button (new Rect (Quitbutton), "back")) {audio.                Playoneshot (beep);            Menupage = "main"; }} else if (Menupage = = "Instructionsb") {GUI.            Label (new Rect (instructions), "Unlocked, select cool run mode"); if (GUI. button (new Rect (Quitbutton), "back")) {audio.                Playoneshot (beep);            Menupage = "main";      }} else if (Menupage = = "INSTRUCTIONSC") {      Gui.            Label (new Rect (instructions), "Unlocked, select cool run mode"); if (GUI. button (new Rect (Quitbutton), "back")) {audio.                Playoneshot (beep);            Menupage = "main"; }} else if (menupage== "test") {//gui.            Label (new Rect (instructions), "Direction key control movement"); if (GUI. button (new Rect (PlayButton), "Truck")) {audio.                Playoneshot (beep);                Menupage = "main";                Startcoroutine ("Buttonaction", "Loading");            Menupage = "Instructionsa"; } if (GUI. button (new Rect (Highscoresbutton), "sports Car")) {audio.                Playoneshot (beep);                Menupage = "main";                Startcoroutine ("Buttonaction", "Loading2");            Menupage = "INSTRUCTIONSB"; } if (GUI. button (new Rect (Instructionsbutton), "Challenge Mode")) {audio.                Playoneshot (beep); Menupage = "Main ";                Startcoroutine ("Buttonaction", "Loading3");            Menupage = "INSTRUCTIONSC"; } if (GUI. button (new Rect (Quitbutton), "back")) {audio.                Playoneshot (beep);            Menupage = "main"; }} GUI.    Endgroup (); } IEnumerator buttonaction (string levelname) {audio.        Playoneshot (beep);                Yield return new waitforseconds (0.35f);        if (levelname!= "quit") {Application.loadlevel (levelname);            } else {application.quit ();        Debug.Log ("have Quit"); }}//update is called once per framevoid update () {}}

sort of stuff.

Link: http://pan.baidu.com/s/1gdxYZnl Password: 3TU2

The position size of some parameter menu can be adjusted by itself



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Exquisite Cup unity development experience--Start menu GUI production

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.