The code you posted should correctly pause the game. If you want a menu to appear, as well, the Unity GUI class will be very helpful. You can find the GUI class in the script reference >here<.
All your GUI commands have to be called from OnGUI(). However, since you already have a paused boolean variable, you could use that to turn on and off your menu. Something like this:
var windowWidth : int = 150;
var windowHeight : int = 200;
var windowRect : Rect = Rect( Screen.width/2 - windowWidth/2, Screen.height/2 - windowHeight/2, windowWidth, windowHeight );
function OnGUI()
{
if( paused )
{
// 3rd parameter is the function where you will place all your GUI controls that should be in the window
GUI.Window( 0, windowRect, PausedWindow, "Paused" );
}
}
function PausedWindow( )
{
//all your buttons or other gui components for your window go here, for example:
GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" )
{
Application.LoadLevel("MainMenu");
}
}
If you add this code to your existing script, anytime your ‘paused’ variable becomes true, the window will appear, and you’d have a button that would load a level named “MainMenu.” If you just want some text that says “Paused” instead of a menu, you could have something like:
function OnGUI()
{
if( paused )
{
GUI.Label( Rect( 50, 50, 150, 30), "PAUSED" );
}
}
However you decide to build your pause menu, I’d recommend using your ‘paused’ variable to turn on and off GUI components called in OnGUI(). I hope this is along the lines you were asking for…I do believe your code pauses the game fine, and that you just want a menu to appear when the game is paused.