2015/07/07////////////
by xbw///////////////////
Environment Unity 4.6.1//////
First on
is not very cute, Meng Meng da;
Words not much to say, first create a scene,,,
Picture sky scene added Sky box,,, say how to add Sky box, I do not like to add Sky box to the main camera, but this method also say, click on the main camera, add ingredients in the Inspector Property Bar, Skybox, and then find the Sky box material, will he assigned to the Sky box is good,
However, this way can not be previewed, can only be seen at run time, is not very uncomfortable ah,
Then look at another way,, in the edit to find the render setting open, found in the Inspector Skybox material, the sky and material to him, will be displayed in the scene immediately, is not very fun ah;
we continue;;;
First, find gameobject--create empty in the menu bar, create an empty object, and we'll name it Menu2;
The following is no nonsense, directly on the code, and adjust the properties of their own good, with the CSharp script
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 instructions; Rect menuareanormalized; String menupage = "main";//use of this for Initializationvoid Start () {menuareanormalized = new Rect uarea.x * Screen.width-(Menuarea.width * 0.5f), MENUAREA.Y * screen.height-(Menuarea.height * 0.5f), Menuarea.width, M Enuarea.height);} void Ongui () {Gui.skin = Menuskin; Gui. BeginGroup (menuareanormalized); if (Menupage = = "Main") {if (GUI. button (new Rect (PlayButton), "Play")) {Startcoroutine ("buttonaction", "second"); Application.loadlevel ("second"); } if (GUI. button (new Rect (Instructionsbutton), "InstruCtions ")) {audio. Playoneshot (beep); Menupage = "Instructions"; } if (GUI. button (new Rect (Quitbutton), "quit")) {Startcoroutine ("buttonaction", "Quit"); }} else if (menupage== "instructions") {GUI. Label (new Rect (instructions), "Awake on a mysterious ... Find A-a-signal for help or face certain doom! "); 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 () {}}
Mount this code to the empty object of Menu2;;;
By adjusting these attributes, the
Where the beep in the code is a sound file, which is the point at which the button will emit the corresponding sound,
Menu Skin This is the menus properties, GUI menu skins, if not add him, the menu is unity comes with the initial state, rather ugly, without I say,,,
After using the menu skin, it will be like the first picture of this article button, shape and color have a great change;
The following describes the detailed process;;;
Create a GUI in the project panel skin is the GUI skins, play the role of beautification;; Rename to main Menu
I modified the font, this only need to drag the font resources in it;
Also modified the button in some of the details to say;
This normal is not the operation of the button look, this background map to drag the picture resources past, as for this text color is no operation of the color;
This hover is the mouse hover over the button when the display, this map and color have a corresponding change,
This active is the response of the mouse click down to respond to changes,
The size of font size is also modified;;;
This is the instructions button click will display a text description, the text color changes;;
Last
is not very cute, followed by the operation of it, I hope we learn from each other Exchange, Midnight 12 o'clock written,
I hope you have more messages, I will give a reply in time.
As for the material resources, I will send the students to the mailbox.;;
It's not too early, I'm going to have a little fun ... Good night!!
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Unity 3D Game Start Interface GUI Landscaping