Menu Close

Unity Tutorial – Creating A Main Menu

11:28 – How to create it and how it works is not stated until after. But sprites will sometimes be split into different quadrants allowing the sprite to be stretched without stretching the artwork. It does this by having one quadrant in the middle that is just a line that doesn’t change when stretched. The quadrants on either side of it, the ones with actually artwork, do not move. Unless it is squished, as it will soon press together the two side quadrants until they are reduced in size, but still keeping the ratio of the dimensions of the artwork equel.

12:25 – To create quadrants on a sprite, start by importing the desired sprite/texture. It may come as a texture, just switch it to a sprite, then select sprite mode to multiple. And click sprite editor, you should see a green box to “slice” the sprite. Move it around numerically, with the table, or by dragging with the mouse. Until the box is inside of the area you want to stretch. For example, if you move the top left corner down a little and to the right. It will form a box in that corner, that is the quadrant that won’t stretch.

16:28 – To create buttons, start by naming the panel under the canvas main menu panel, then while the panel is selected, click GameObject in the tab bar on the top, then UI, and button. The button will have colors you can change so that its normal color and the color when it is pressed are different. To change the text presented on the button, click the button in the hierarchy to see its child objects. Which should be text, click it, and change the text in the inspector. You can change color and font.

23:06 – The buttons created under the panel will automatically space themselves out vertically within the borders of the panel. To change the spacing between the buttons and the panel, click the main menu panel, and go to to Vertical Layout Group inside the inspector of that object. With this you can change how far the buttons are from any side of the panel’s borders. Tip by instructor, periodically click the play button, as the play mode and edit mode can look different.

29:21 – To change the order of buttons, sliders, or text, just change the order in the hierarchy. Usually in unity the order doesn’t matter.

33:13 – To set the panel so that it looks the same in both the edit and game mode. Select the panel under the canvas, look in the inspector for Canvas scaler, click UI scale mode, and select scale with screen size. Input the size of your screen and it should appear equal in both the edit and play/game mode now.

57:30, 49:45, and 37:36 – The three completed scripts used in the menu. 57 minutes is the script to allow using arrow keys to navigate the menu. 49 minutes is the quit button script to exit out of unity. 37 minutes is the script to change scenes when a button is pressed.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *