-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuController.cs
More file actions
73 lines (56 loc) · 1.5 KB
/
Copy pathMenuController.cs
File metadata and controls
73 lines (56 loc) · 1.5 KB
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
69
70
71
72
73
//MenuController
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;
public class MenuController : MinoBehaviour
{
[Header("Volume Setting")]
[SerializedField] private Text volumeTextValue = null;
//Text Mesh Pro [SerializedField] private TMP_Text volumeTextValue = null;
[SerializedField] Slider volumeSlider = null;
[SerializedField] private float defaultVolume = 1.0f;
[SerializedField] private GameObject confirmationPrompt = null;
[Header("Levels To Load")]
public string _newGameLevel;
private string levelToLoad;
[SerializedField] private GameObject noSavedGameDialog = null;
}
public void NewGameDialogYes()
{
SceneManager.LoadScene(_newGameLevel);
}
public void LoadGameDialogYes()
{
if (PlayerPrefs.HasKey("SavedLevel"))
{
levelToLoad = PlayerPrefs.GetString("SavedLevel");
SceneManager.LoadScene(levelToLoad);
}
else
{
noSavedGameDialog.SetActive(true);
}
}
public void ExitButton()
{
Application.Quit();
}
public void SetVolume(float volume)
{
AudioListener.volume = volume;
volumeTextValue.text = volume.ToString("0.0");
}
public void VolumeApply()
{
PlayerPrefs.SetFloat("mastervolume", AudioListener.volume);
StartCoroutine(ConfirmationBox());
}
public IEnumerator ConfirmationBox()
{
confirmationPrompt.SetActive(true);
yield return new WaitForSectonds(2);
confirmationPrompt.SetActive(false);
}