-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPixelCamera.cs
34 lines (29 loc) · 857 Bytes
/
PixelCamera.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
using UnityEngine;
namespace Binocle
{
[ExecuteInEditMode]
public class PixelCamera : MonoBehaviour
{
public int DesignWidth = 320;
public int DesignHeight = 240;
public Camera _camera;
public int Scaling = 1;
// Use this for initialization
void Start()
{
_camera = gameObject.GetComponent<Camera>();
}
void LateUpdate()
{
int w = Screen.width;
int h = Screen.height;
int m = h / DesignHeight;
if (m < 1)
m = 1;
float ratio = h / (float)(DesignHeight * m);
//Debug.Log ("w: " + DesignWidth + " h: " + DesignHeight + " m: " + m + " ratio: " + ratio);
_camera.orthographicSize = DesignHeight * ratio / 2;
Scaling = m;
}
}
}