| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using UnityEngine; |
| | | 4 | | using UnityEngine.UI; |
| | | 5 | | |
| | | 6 | | public class RunPC : MonoBehaviour |
| | | 7 | | { |
| | | 8 | | public GameObject canvas; |
| | 2 | 9 | | private bool Isvisible = false; |
| | | 10 | | |
| | | 11 | | public AudioSource source; |
| | | 12 | | [SerializeField] |
| | | 13 | | private AudioClip StartSound; |
| | | 14 | | [SerializeField] |
| | | 15 | | private AudioClip EndSound; |
| | | 16 | | |
| | | 17 | | public void TogglePC() |
| | 1 | 18 | | { |
| | 1 | 19 | | if (!Isvisible) |
| | 1 | 20 | | { |
| | 1 | 21 | | StartPC(); |
| | 1 | 22 | | } |
| | | 23 | | else |
| | 0 | 24 | | { |
| | 0 | 25 | | ShutDownPC(); |
| | 0 | 26 | | } |
| | 1 | 27 | | } |
| | | 28 | | |
| | | 29 | | private void StartPC() |
| | 1 | 30 | | { |
| | 1 | 31 | | canvas.SetActive(true); |
| | 1 | 32 | | source.clip = StartSound; |
| | 1 | 33 | | source.Play(); |
| | 1 | 34 | | Isvisible = true; |
| | 1 | 35 | | } |
| | | 36 | | |
| | | 37 | | private void ShutDownPC() |
| | 0 | 38 | | { |
| | 0 | 39 | | canvas.SetActive(false); |
| | 0 | 40 | | source.clip = EndSound; |
| | 0 | 41 | | source.Play(); |
| | 0 | 42 | | Isvisible = false; |
| | 0 | 43 | | } |
| | | 44 | | } |