• Register

This member has provided no bio about themself...

Comment History
KyleHatch
KyleHatch - - 2 comments @ How to create an in-game pause menu?

you'll need to add the line

logoTexture = (Texture2D) Resources.Load("Textures/Menu/paused");

at the start of thePauseMenu() for a texture to show up, change the path to whatever your texture is called and where it is. Don't need the extension for the file.

If you edit the class so that the script is attached to an object, then just make the GUISKin and Texture2D public to edit in the inspector.

Good karma+2 votes
KyleHatch
KyleHatch - - 2 comments @ How to create an in-game pause menu?

using UnityEngine;
using System.Collections;

public class PauseMenu : MonoBehaviour
{
GUISkin newSkin;
Texture2D logoTexture;

public void thePauseMenu()
{
//layout start
GUI.BeginGroup(new Rect(Screen.width / 2 - 150, 50, 300, 250));


//the menu background box

GUI.Box(new Rect(0, 0, 300, 250), "");

//logo picture

GUI.Label(new Rect(15, 10, 300, 68), logoTexture);


///////pause menu buttons

//game resume button

if(GUI.Button(new Rect(55, 100, 180, 40), "Resume"))

{

//resume the game

Time.timeScale = 1.0f;

Destroy(this);

}


//main menu return button (level 0)

if(GUI.Button(new Rect(55, 150, 180, 40), "Main Menu"))

{

Application.LoadLevel(0);

}


//quit button

if(GUI.Button(new Rect(55, 200, 180, 40), "Quit"))

{

Application.Quit();

}


//layout end

GUI.EndGroup();


}


void OnGUI ()

{

//load GUI skin

GUI.skin = newSkin;


//show the mouse cursor

Screen.showCursor = true;


//run the pause menu script

thePauseMenu();

}

}

----

sorry about the spacing, but theres a general c# class called PauseMenu().

I don't attach it to a script but call it from another, but it should do the same job. It can be edited to do as needed!

called in attached script via;

Time.timeScale = 0.0f;
gameObject.AddComponent("PauseMenu");

---

enjoy

Good karma+2 votes