-
Notifications
You must be signed in to change notification settings - Fork 0
/
PausePanel.cs
68 lines (53 loc) · 1.42 KB
/
PausePanel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
using UnityEngine.UI;
public class PausePanel : MonoBehaviour
{
private AudioManager am;
public Slider SoundSlider;
public Slider MusicSlider;
[SerializeField] GameObject pausePanel;
private void Start(){
am = GameObject.Find("AudioManager").GetComponent<AudioManager>();
}
// start spil igen
public void Resume()
{
Time.timeScale = 1;
pausePanel.SetActive(false);
}
// load aktive scene
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
Time.timeScale = 1;
}
// gå til main menu
public void MainMenu(){
Time.timeScale = 1;
OnSceneLeave();
SceneManager.LoadScene(0);
}
// luk spillet
public void Quit(){
Application.Quit();
}
// håndter input
private void Update(){
if(Input.GetKeyDown(KeyCode.Escape)){
if (pausePanel.activeSelf){
Resume();
}else{
pausePanel.SetActive(true);
Time.timeScale = 0;
}
}
}
private void OnSceneLeave(){
// opdater audiomanageres gemte sprites
am.SpriteStatus();
}
}