Skip to content

Commit

Permalink
Restrict resolution to 16:9
Browse files Browse the repository at this point in the history
  • Loading branch information
TLChicken committed Aug 15, 2021
1 parent 6d1cd0a commit 3300b94
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Assets/Scripts/Main Menu/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ void Start() {
resolutionDropdown.ClearOptions();
List<string> options = new List<string>();

int currentResolutionIndex = 0;
int currentResolutionIndex = -1;
int amtOfIndexToRm = 0;

for (int i = 0; i < resolutions.Length; i++) {
string option = resolutions[i].width + " x " + resolutions[i].height;

if (!options.Contains(option)) {
if (!options.Contains(option) && ((resolutions[i].width / 16).Equals(resolutions[i].height / 9))) {
options.Add(option);
} else {
if (currentResolutionIndex == -1) {
amtOfIndexToRm = amtOfIndexToRm + 1;
}
}

// comparison to update the resolution at the start
Expand All @@ -39,7 +44,8 @@ void Start() {
}

resolutionDropdown.AddOptions(options);
resolutionDropdown.value = currentResolutionIndex;
resolutionDropdown.value = currentResolutionIndex - amtOfIndexToRm >= 0 ? currentResolutionIndex - amtOfIndexToRm : 0;
Debug.Log("Resolution Dropdown Chosen Index at: " + resolutionDropdown.value);
resolutionDropdown.RefreshShownValue();

if (GameMgrSingleton.GM != null) {
Expand Down

0 comments on commit 3300b94

Please sign in to comment.