har5452

Untitled

Feb 15th, 2025
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class pause : MonoBehaviour
  6. {
  7. public static bool GamePaused = false;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11.  
  12. }
  13.  
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. if (Input.GetKeyDown(KeyCode.Return))
  18. {
  19. if(GamePaused == false){
  20. PauseGame();
  21.  
  22. }
  23. else {
  24. ResumeGame();
  25. }
  26. }
  27.  
  28. if(GamePaused == true){
  29. Time.timeScale = 0f;
  30. }
  31. else {
  32. Time.timeScale = 1f;
  33. }
  34. }
  35.  
  36. void PauseGame ()
  37. {
  38. print("paused");
  39. GamePaused = true;
  40. }
  41. void ResumeGame ()
  42. {
  43. print("unpaused");
  44. GamePaused = false;
  45. }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment