Added pause menu
Pause menu with settings
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user