Home page in unity 3d


How can can i create a homepage in unity 3d game.
While game over how can i make resume, home, replay buttons

Thanks in Advance

This is only one way to perform this; you could do it a number of different ways. I should let you know I did not test this particular script yet, but let me know if you get any errors that you can’t debug and I can help ya out (this is JS).

Create and save a Scene (named MenuLevel or similar), in your Build settings click the Add Current button under Scenes To Build. Then remember the index of this (if it was your first scene, it will be at index 0; not unlike counting in arrays). You can use


to call the menu at any point during the game. If your index is something other than zero, you would of course use that number. I am going to use a GUI based approach, there are other ways of doing this.

In your new menu scene add a script to your MainCamera called MenuGUI or the like (or make another object that will persist throughout the menu and add it to that object). In this new script use the OnGUI function to create your GUI.

Check out the OnGUI function and the GUI and GUI.Button classes in the scripting reference, then you can use something like this for your home screen/main menu:

private var menu : String = "main";

function OnGUI(){
        case "main":
                menu = "levels";
        case "levels":
                menu = "main";
            //add your individual level buttons here,
            // or use a for loop that cycles through the
            // amount of levels you have, and create
            // a button using adjusted x and y Rectangle
            // coordinates for each button. If any of the
            // buttons are pressed, you will call 
            // Application.LoadLevel(); using the corresponding
            // level's index in your build settings.

for a menu for your levels, use something like this on your main camera (or, again, another persisting object):

private var showMenu : boolean = false;

function Update(){
     if(Input.GetButtonUp("escape") && !showMenu){
          //Below is a good pause method if your moving,
          // and physics based objects use Time.deltaTime
          // to apply movement and physics.
          Time.timeScale = 0;  //pause game
          showMenu = true;  //show menu

function OnGUI(){
            Time.timeScale = 1; //un-pause game
            showMenu = false;  //hide menu
            Application.LoadLevel(0); //load MainMenu scene

use this event OnApplicationPause(bool pause) to listen the event of home button pressed

Use the GUI functions inside your OnGUI function.

Take a look at Unity - Manual: IMGUI Basics with code examples.

If that doesn´t help, provide more information and needs to offer useful help, be more specific.