forked from llapuras/SomeUnityScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResolutionModifier.cs
More file actions
64 lines (51 loc) · 1.79 KB
/
ResolutionModifier.cs
File metadata and controls
64 lines (51 loc) · 1.79 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ResolutionModifier : MonoBehaviour
{
public Camera cam;
public RawImage alfx0;
private int targetWidth = Screen.width;
private int targetHeight = Screen.height;
private void Start() {
ChangeResolution(targetWidth, targetHeight, FilterMode.Bilinear);
}
void OnGUI()
{
//originx4
if (GUI.Button(new Rect(1000, 40, 100, 30), "orignx4")){
ChangeResolution(targetWidth*4, targetHeight*4, FilterMode.Bilinear);
}
//originx2
if (GUI.Button(new Rect(1000, 80, 100, 30), "orignx2")){
ChangeResolution(targetWidth*2, targetHeight*2, FilterMode.Bilinear);
}
//origin
if (GUI.Button(new Rect(1000, 120, 100, 30), "orign")){
ChangeResolution(targetWidth, targetHeight, FilterMode.Bilinear);
}
//0.5
if (GUI.Button(new Rect(1000, 160, 100, 30), "orign/2")){
ChangeResolution(targetWidth/2, targetHeight/2, FilterMode.Point);
}
//0.25
if (GUI.Button(new Rect(1000, 200, 100, 30), "orign/4")){
ChangeResolution(targetWidth/4, targetHeight/4, FilterMode.Point);
}
//0.125
if (GUI.Button(new Rect(1000, 240, 100, 30), "orign/8")){
ChangeResolution(targetWidth/8, targetHeight/8, FilterMode.Point);
}
}
void ChangeResolution(int width, int height, FilterMode mode){
if ( cam.targetTexture != null )
{
cam.targetTexture.Release( );
}
RenderTexture al = new RenderTexture(width, height, 24);
mode = FilterMode.Bilinear;
al.filterMode = mode;
cam.targetTexture = al;
alfx0.texture = al;
}
}