x


A trigged pause menu

Can some one give me a script for a trigged pause menu with a resume button. So my car drives throught the collider, it pauses, and then to resume i have to click the resume button?

more ▼

asked Feb 13 '12 at 07:07 AM

Spilker gravatar image

Spilker
1 1 2 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

How about this?

// Set this up in the inspector
public Collider car;
bool paused = false;
void OnTriggerEnter(Collider other)
{
    if(other == car)
    {
        paused = true;
        Time.timeScale = 0;
    }
}

void OnGUI
{
    if(paused)
    {
        GUILayout.FlexibleSpace();
        GUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        if(GUILayout.Button("Unpause")
        {
            Time.timeScale = 1;
            paused = false;
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
        GUILayout.FlexibleSpace();
    }
}
more ▼

answered Feb 13 '12 at 07:19 AM

syclamoth gravatar image

syclamoth
14.8k 7 15 80

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x279
x260
x101

asked: Feb 13 '12 at 07:07 AM

Seen: 429 times

Last Updated: Feb 13 '12 at 07:19 AM