- Home /
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?
Comment
Answer by syclamoth · Feb 13, 2012 at 07:19 AM
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();
}
}
Your answer
Follow this Question
Related Questions
Insane problem with triggers 2 Answers
How do I prevent multiple triggers using OnTriggerEnter? 1 Answer
How to have multiple colliders intersect without colliding with each other? 1 Answer
[Unity 4.6.1] Weird bug between 2 Colliders 1 Answer
Can I make a collider ignore only one other collider? 0 Answers