Advertisement
soft699

menupause

Sep 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6.  
  7. public class Pausegame : MonoBehaviour {
  8.  
  9. private bool Pause = false;
  10. public Transform canvas;
  11.  
  12.  
  13. void Start () {
  14.  
  15.  
  16.  
  17. }
  18.  
  19.  
  20. void Update () {
  21.  
  22. if(Input.GetKeyDown(KeyCode.P))
  23. if (canvas.gameObject.activeInHierarchy == false)
  24. {
  25. canvas.gameObject.SetActive(true);
  26. Time.timeScale = 0;
  27. GameObject.Find("Player").GetComponent<Player>().enabled = false;
  28. }
  29. else
  30. {
  31. canvas.gameObject.SetActive(false);
  32. Time.timeScale = 1;
  33. GameObject.Find("Player").GetComponent<Player>().enabled = true;
  34. }
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement