mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-09-11 08:17:01 +00:00
Added Graphics Settings
This commit is contained in:
1 parent
70f8c81cdf
commit
0ef0e6388f
11 files changed
+5421
-197
No files matched your search
@@ -0,0 +1,100 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class OptionsScreen : MonoBehaviour
|
||||
{
|
||||
|
||||
public Toggle fullscreenTog, vsyncTog;
|
||||
public List<ResItem> resolutions = new List<ResItem>();
|
||||
private int selectedResolution;
|
||||
public TMP_Text resolutionLabel;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
fullscreenTog.isOn = Screen.fullScreen;
|
||||
|
||||
if (QualitySettings.vSyncCount == 0)
|
||||
{
|
||||
vsyncTog.isOn = false;
|
||||
} else
|
||||
{
|
||||
vsyncTog.isOn = true;
|
||||
}
|
||||
|
||||
bool foundRes = false;
|
||||
for (int i = 0; i < resolutions.Count; i++)
|
||||
{
|
||||
if (Screen.width == resolutions[i].horizontal && Screen.height == resolutions[i].vertical)
|
||||
{
|
||||
foundRes = true;
|
||||
selectedResolution = i;
|
||||
UpdateResLabel();
|
||||
}
|
||||
}
|
||||
if (!foundRes)
|
||||
{
|
||||
ResItem newRes = new ResItem();
|
||||
newRes.horizontal = Screen.width;
|
||||
newRes.vertical = Screen.height;
|
||||
resolutions.Add(newRes);
|
||||
selectedResolution = resolutions.Count - 1;
|
||||
UpdateResLabel();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ResLeft()
|
||||
{
|
||||
selectedResolution--;
|
||||
if (selectedResolution < 0)
|
||||
{
|
||||
selectedResolution = resolutions.Count - 1;
|
||||
}
|
||||
UpdateResLabel();
|
||||
}
|
||||
|
||||
public void ResRight()
|
||||
{
|
||||
selectedResolution++;
|
||||
if (selectedResolution > resolutions.Count - 1)
|
||||
{
|
||||
selectedResolution = 0;
|
||||
}
|
||||
UpdateResLabel();
|
||||
}
|
||||
|
||||
public void UpdateResLabel()
|
||||
{
|
||||
resolutionLabel.text = resolutions[selectedResolution].horizontal.ToString() + " x " + resolutions[selectedResolution].vertical.ToString();
|
||||
}
|
||||
public void ApplyGraphics()
|
||||
{
|
||||
//Screen.fullScreen = fullscreenTog.isOn;
|
||||
|
||||
if (vsyncTog.isOn)
|
||||
{
|
||||
QualitySettings.vSyncCount = 1;
|
||||
} else
|
||||
{
|
||||
QualitySettings.vSyncCount = 0;
|
||||
}
|
||||
|
||||
Screen.SetResolution(resolutions[selectedResolution].horizontal, resolutions[selectedResolution].vertical, fullscreenTog.isOn);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
[System.Serializable]
|
||||
public class ResItem
|
||||
{
|
||||
public int horizontal, vertical;
|
||||
}
|
||||
Reference in new issue
Block a user