- Home /
Menu in C#
Hello,
I am new to C# and a bit stuck on making a menu screen (2 buttons, one for the game and one for a how-to-play with images).
Is there a good tutorial on the webs that explains this easily or can someone give me a helping hand?
Thanks in advance
Answer by Suraci · Jun 06, 2012 at 10:15 AM
You could use 3D text to create a simple menu.
using UnityEngine;
using System.Collections;
public class MenuObject : MonoBehaviour
{
public bool isQuit = false;
void OnMouseEnter()
{
renderer.material.color = Color.blue;
}
void OnMouseExit()
{
renderer.material.color = Color.white;
}
void OnMouseDown()
{
if(isQuit)
{
Application.Quit();
}
else
{
Application.LoadLevel(1); //Make sure that level "1" is located in your build settings. You can also change the 1 with a name of your scene.
}
}
}
Make 2x a 3D text, One named Start game and the other Quit game. Make sure you highlight the public bool "is Quit" and it's working :).
Answer by Berenger · Jun 05, 2012 at 03:06 PM
Could take a look at that.
Basically, you need to declare a function OnGUI inside a script attached to a gameObject. Inside that function, you need to use GUI functions to draw stuff. In your case GUI.Button and probably GUI.Label. Keep in mind that OnGUI is called several times per frame, by Unity, so you mustn't calcul anything heavy in there.
Your answer
Follow this Question
Related Questions
item shop menu screen 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to make game recognise Screen resolution on startup 1 Answer
Change the position of a UI component through pressing a UI Button 1 Answer