Files
findthesource/Assets/Scripts/menu/OptionMenu.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2022-11-16 11:23:25 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
public class OptionMenu : MonoBehaviour
{
//Resolution
Resolution[] resolutions;
public Dropdown resolutionDropdown;
private void Start() {
resolutions = Screen.resolutions;
resolutionDropdown.ClearOptions();
List<string> options = new List<string>();
int currentResIndex = 0;
for (int i = 0; i < resolutions.Length; i++) {
2022-12-12 11:48:17 +01:00
string option = resolutions[i].width + " x " + resolutions[i].height + " @"+resolutions[i].refreshRate;
2022-11-16 11:23:25 +01:00
options.Add(option);
if(resolutions[i].width == Screen.currentResolution.width && resolutions[i].height == Screen.currentResolution.height) {
currentResIndex = i;
}
}
resolutionDropdown.AddOptions(options);
resolutionDropdown.value = currentResIndex;
2022-12-12 11:48:17 +01:00
//resolutionDropdown.itemText.fontSize = 18;
2022-11-16 11:23:25 +01:00
resolutionDropdown.RefreshShownValue();
}
public void setResolution(int resolutionIndex) {
Resolution resolution = resolutions[resolutionIndex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
}
//Quality
public void setQuality(int qualityIndex) {
QualitySettings.SetQualityLevel(qualityIndex);
}
//Fullscreen
public void setFullscreen(bool isFullscreen) {
Screen.fullScreen = isFullscreen;
}
2022-11-16 12:24:47 +01:00
2023-02-10 16:13:26 +01:00
/*public void setVsync(bool value) {
2022-11-16 12:24:47 +01:00
int num = 0;
if (value) num = 1;
else num = 0;
if (num > 0) Debug.Log("vsync on");
else Debug.Log("vsync off");
QualitySettings.vSyncCount = num;
2023-02-10 16:13:26 +01:00
}*/
2022-11-16 11:23:25 +01:00
}