-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathResolutionSetting.cs
38 lines (37 loc) · 1.53 KB
/
ResolutionSetting.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResolutionSetting : GeneralUISystemWithNavigation
{
WindowUI systemWindow;
List<(int, int)> activeResolutionList;
protected override void InitializeUI()
{
systemWindow ??= NewWindow("ui_system_resolution", DefaultSetup);
AddText("When ever resolution changes, need to clear cache of window location.", systemWindow);
activeResolutionList = ResolutionUtility.AvailableResolutions();
for (int i = 0; i < activeResolutionList.Count; i++)
{
(int width, int height) = activeResolutionList[i];
ToggleUIExclusive toggle = AddExclusiveToggle(width + "x" + height, systemWindow, _ => UpdateResolution());
if (width == Screen.width && height == Screen.height)
toggle.Set = true;
}
AddGap(systemWindow);
AddText("Both camera and overlay mode of canvas are supported.", systemWindow);
SliderUIChoice uiMode = AddSliderWithChoice("Canvas Mode", systemWindow, ChangeCanvasMode);
uiMode.AddChoice("Screen Space - Camera");
uiMode.AddChoice("Screen Space - Overlay");
systemWindow.Resize(50);
}
void UpdateResolution()
{
(int width, int height) = activeResolutionList[currentSelection[1]];
ResolutionUtility.SetResolution(width, height);
UIManager.Instance.ClearAllWindowLocation();
}
void ChangeCanvasMode(int mode)
{
UIManager.Instance.SetOverlayMode(mode == 1);
}
}