Added pause menu
Pause menu with settings
This commit is contained in:
@@ -22,7 +22,7 @@ public class GameOverScreen : MonoBehaviour
|
||||
{
|
||||
Time.timeScale = 1;
|
||||
SceneManager.LoadScene("SampleScene");
|
||||
}
|
||||
}
|
||||
|
||||
public void ExitButton()
|
||||
{
|
||||
|
||||
42
3D FPS/Assets/Scripts/PauseScreen.cs
Normal file
42
3D FPS/Assets/Scripts/PauseScreen.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class PauseScreen : MonoBehaviour
|
||||
{
|
||||
public GameObject pauseMenu;
|
||||
public GameObject settingsMenu;
|
||||
void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Time.timeScale = 0;
|
||||
pauseMenu.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartButtonn()
|
||||
{
|
||||
Time.timeScale = 1;
|
||||
SceneManager.LoadScene("SampleScene");
|
||||
}
|
||||
|
||||
public void ExitButtonn()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public void ContinueButtonn()
|
||||
{
|
||||
Time.timeScale = 1;
|
||||
pauseMenu.SetActive(false);
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
|
||||
public void SettingButtonn()
|
||||
{
|
||||
settingsMenu.SetActive(true);
|
||||
}
|
||||
}
|
||||
11
3D FPS/Assets/Scripts/PauseScreen.cs.meta
Normal file
11
3D FPS/Assets/Scripts/PauseScreen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 505700cfdc1c9a64d904be94a71e2781
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
3D FPS/Assets/Scripts/SettingsMenu.cs
Normal file
58
3D FPS/Assets/Scripts/SettingsMenu.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsMenu : MonoBehaviour
|
||||
{
|
||||
public AudioMixer audioMixer;
|
||||
|
||||
public TMP_Dropdown resolutionDropdown;
|
||||
|
||||
Resolution[] resolutions;
|
||||
int currentResolutionIndex;
|
||||
|
||||
void Start()
|
||||
{
|
||||
resolutions = Screen.resolutions;
|
||||
|
||||
resolutionDropdown.ClearOptions();
|
||||
List<string> options = new List<string>();
|
||||
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
string option = resolutions[i].width + " x " + resolutions[i].height;
|
||||
options.Add(option);
|
||||
if(resolutions[i].width == Screen.width && resolutions[i].height == Screen.height) currentResolutionIndex = i;
|
||||
}
|
||||
resolutionDropdown.AddOptions(options);
|
||||
resolutionDropdown.value = currentResolutionIndex;
|
||||
resolutionDropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
public void ContinueButton()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void setVolume(float vol)
|
||||
{
|
||||
audioMixer.SetFloat("Volume", vol);
|
||||
}
|
||||
|
||||
public void setQuality(int qualityIndex)
|
||||
{
|
||||
QualitySettings.SetQualityLevel(qualityIndex);
|
||||
}
|
||||
|
||||
public void setFullscreen(bool isFullscreen)
|
||||
{
|
||||
Screen.fullScreen = isFullscreen;
|
||||
}
|
||||
public void setResolution(int resolutionIndex)
|
||||
{
|
||||
Screen.SetResolution(resolutions[resolutionIndex].width, resolutions[resolutionIndex].height, FullScreenMode.FullScreenWindow);
|
||||
}
|
||||
}
|
||||
11
3D FPS/Assets/Scripts/SettingsMenu.cs.meta
Normal file
11
3D FPS/Assets/Scripts/SettingsMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc78eb88235f0d8488d07c05df94a479
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user