blob: 15a8ce78393d7a861739b4767dba654b7226c2a9 (
plain)
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
39
40
41
42
43
44
|
using System;
using UnityEngine;
public static class ResolutionManager
{
public static event Action<float> ResolutionChanged;
public static void SetResolution(int width, int height, bool fullscreen)
{
Action<float> resolutionChanged = ResolutionManager.ResolutionChanged;
if (resolutionChanged != null)
{
resolutionChanged((float)width / (float)height);
}
Screen.SetResolution(width, height, fullscreen);
}
public static void ToggleFullscreen()
{
bool flag = !Screen.fullScreen;
int width;
int height;
if (flag)
{
Resolution[] resolutions = Screen.resolutions;
Resolution resolution = resolutions[0];
for (int i = 0; i < resolutions.Length; i++)
{
if (resolution.height < resolutions[i].height)
{
resolution = resolutions[i];
}
}
width = resolution.width;
height = resolution.height;
}
else
{
width = 711;
height = 400;
}
ResolutionManager.SetResolution(width, height, flag);
}
}
|