Hi everyone first i want to thank you for your help, me and my friends we try to create a game (i hope in two weeks to be published) the only problem is that i have some big problems with the menu.I have create the menu screen with text and some animation but the thing is i don’t know how to access the option menu.I have try everything but i cannot find a solution i have watch so many tutorials but they do not say anything about the options like sound,graphics,resolution.The only thing that i want is some ideas what exactly to do.Also i want to ask another question can i use a script that every time i press a button at the menu screen to open the specific package/file at the level?Like if i press the credits to open a package/file for the credits?I know that i am asking a lot but like i said i want to be perfect so please if anyone can help.
Hello there brother. There are two ways to create a game menu:
- 3D Text
- GUI Text
Both have their pros and cons, but both will get the job done, and believe me, youtube tutroials will teach you a lot (I’ll post some links below)
However, to get you started here is a GUI Javascript code for Play, Quit, and settings. While the Play and quit buttons work, the setting doesn’t, so you could set it to anything
var hSliderValue : float = 0.0;
function OnGUI () {
if (GUI.Button (Rect (300, 50, 200, 40), "Single Player")) {
Application.LoadLevel(1);
}
if (GUI.Button (Rect (300, 150, 200, 40), "Quit")) {
Application.Quit();
}
if (GUI.Button (Rect (300, 100, 200, 40), "Settings")) {
}
}
On the other hand, here is something that you could apply to 3D Text object that will make it work like a menu.
using UnityEngine;
using System.Collections;
public class MenuObject : MonoBehaviour
{
public bool isQuit = false;
void OnMouseEnter()
{
renderer.material.color = Color.green;
}
void OnMouseExit()
{
renderer.material.color = Color.white;
}
void OnMouseDown ()
{
if(isQuit)
{
Application.Quit();
}
else
{
Application.LoadLevel (1);
}
}
}
These are some links of videos that will teach you how to make menus in unity:
https://www.youtube.com/watch?v=IGIDPqSLekE
Thanks for the help but i have seen this tutorial’s they help me a lot about the construction of the menu but my problem is the settings of the menu like resolution and the music but again thanks for the help.
i can only answer your question: can i use a script that every time i press a button at the menu screen to open the specific package/file at the level?
here is the code:
//In the inspector, write the name of the scene the credits are in
var Credits : String;
//Insert the GUI collision of the text here, just make a cube, remove the mesh and scale it to the text size
var ShowCredits : GameObject;
function OnMouseUp()
{
if (ShowCredits)
{
Application.LoadLevel(Credits);
}
}
i have not tried this b4, but hope it helps. plus i am not so good at guessing stuff. this is my first answer