CustomAppScaling.cs
1.54 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CustomAppScaling : MonoBehaviour {
private Rect rect;
void Awake () {
rect = GetComponent<RectTransform>().rect;
if (rect.width == 4098 && rect.height == 1536)
{
//Globacore foyer touch wall testing
GetComponent<CanvasScaler>().scaleFactor = (rect.height / (1080f * 4)) * 2;
GameObject orbbec = GameObject.Find("Orbbec Sensors");
if (orbbec)
orbbec.SetActive(false);
}
else
{
GetComponent<CanvasScaler>().scaleFactor = Mathf.Min(rect.width / (1920f * 4), rect.height / (1080f * 4));
}
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
GetComponent<CanvasScaler>().scaleFactor = Mathf.Min(rect.width / 1920f, rect.height / 1080f);
}
else if (Input.GetKeyDown(KeyCode.Alpha2))
{
if (rect.width == 4098 && rect.height == 1536)
{
GetComponent<CanvasScaler>().scaleFactor = (rect.height / (1080f * 4)) * 2;
}
else
{
GetComponent<CanvasScaler>().scaleFactor = Mathf.Min(rect.width / (1920f * 2), rect.height / (1080f * 2));
}
}
else if (Input.GetKeyDown(KeyCode.Alpha3))
{
GetComponent<CanvasScaler>().scaleFactor = Mathf.Min(rect.width / (1920f * 4), rect.height / (1080f * 4));
}
}
}