View difference between Paste ID: igqmBnD0 and aLrgrt4i
SHOW: | | - or go back to the newest paste.
1
using System;
2
 using UnityEngine;
3
 
4
 public class pause : MonoBehaviour
5
 {
6
     bool paused = false;
7
 
8
     void Update()
9
     {
10-
         if(Input.GetButtonDown("pauseButton"))
10+
         if(Input.GetButtonDown("escape"))
11
             paused = togglePause();
12
     }
13
     
14
     void OnGUI()
15
     {
16
         if(paused)
17
         {
18
             GUILayout.Label("Game is paused!");
19
             if(GUILayout.Button("Click me to unpause"))
20
                 paused = togglePause();
21
         }
22
     }
23
     
24
     bool togglePause()
25
     {
26
         if(Time.timeScale == 0f)
27
         {
28
             Time.timeScale = 1f;
29
             return(false);
30
         }
31
         else
32
         {
33
             Time.timeScale = 0f;
34
             return(true);    
35
         }
36
     }
37
 }