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 options = new List(); 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); } }