Introduction: How To Make A Main Menu in Unity
Introduction: How To Make A Main Menu in Unity
Menu includes:
Customized background.
Step 1: Make a Plane & Position It in Front of the
Camera
When you are done, it should look similar to the image above.
Step 2: Light It Up
Once again, see the image for what this should look like when you
have completed the step.
Step 3: Add a Texture
Create a new folder called Textures in your Assets folder for the
Unity project you are working on. Right click the folder in the
Project panel in Unity and select, "Show in Explorer." Copy and
paste the picture you took into the Textures folder.
With your Background selected in the Hierarchy, click and drag
the picture from the Textures folder in the Project panel to
Inspector panel, where it should be added as the new texture for
the background. See the image.
Rename the 3D Text object and enter the text you want it to
display in its Text Mesh component in the Inspector.
Rotate it 90 degrees about the X or Z axis so that is displays
properly in the camera's view.
Drag the 3D text object into the empty Text game object in the
Hierarchy. Be
You already have lots of fonts. You can access them (on
Windows) by opening Explorer and going to the folder called
Fonts, which is located under OS/Windows/Fonts.
In the Unity project panel, create a new folder in Assets and call it
Fonts, as well.
Copy and paste the fonts you want for your Unity project from your
computer's fonts folder to the new Fonts folder you created within
the Assets folder for your project.
Note: This will most likely copy over several different files for
each font, one for regular, bold, italic, etc.
Select the 3D text whose font you want to change in the Hierarchy
panel, and drag the desired font from the fonts folder in the project
panel to the box labeled "font" in the Text Mesh component in the
Inspector.
You can change the font color, size, and other other attributes in
the Text Mesh component of the 3D text. This will appear in the
Inspector panel, provided you have the 3D text you want to edit
selected in the Hierarchy.
The text will most likely look a little blurry. You can clean this up by
making the font size significantly larger, though this will mess up
the camera's view at this point, so you would have to readjust the
camera and the background plane's size.
Step 6: Make the Text Change Color When You
Hover Over It
There are three functions in this script. The first tells the text to be
its original color. The second tells the text to change color when
the mouse is touching it, and the third tells the text to go back to
its original color after the mouse is no longer hovering over it.
void Start(){
renderer.material.color = Color.black;
void OnMouseEnter(){
renderer.material.color = Color.red;
void OnMouseExit() {
renderer.material.color = Color.black;
Add the script to each piece of text by dragging it from the project
panel to the 3D text object's name in the Hierarchy.
Test whether your buttons change color by clicking the play button
at the top middle of the screen and hovering your mouse.
Step 7: Write a Script to Control the Buttons
void OnMouseUp(){
if(isStart)
Application.LoadLevel(1);
if (isQuit)
Application.Quit();
}
Application.LoadLevel(1) loads scene number 1 of the game. (The
menu scene should be level 0. You can change which scene is
which in Build Settings, under File.)
That's it, you are done! You can add an additional line of code to
your MainMenu script to make sure it is working. Just tell it to
change the color of the button when you click it (to a different color
than when you hover over it).
void OnMouseUp() {
if (isQuit) {
Application.Quit ();
} if(isStart) {
Application.LoadLevel (1);
renderer.material.color=Color.cyan;
http://www.instructables.com/id/How-to-make-a-main-menu-in-Unity/