I'm writing a 2d game in unity and would like to force the orthogonal camera's view frustum to be altered only on the right-hand side according to the device's aspect ratio, with the left/bottom being set to 0,0
Code
void OnDrawGizmosSelected() {
//top-Right
Gizmos.color = Color.red;
Gizmos.DrawSphere(new Vector3(Camera.main.orthographicSize * Camera.main.aspect, Camera.main.orthographicSize, transform.position.z), 1f);
// down- Right
Gizmos.color = Color.white;
Gizmos.DrawSphere(new Vector3(Camera.main.orthographicSize * Camera.main.aspect, -Camera.main.orthographicSize, transform.position.z), 1f);
//top -left
Gizmos.color = Color.green;
Gizmos.DrawSphere(new Vector3((-Camera.main.orthographicSize) * Camera.main.aspect, Camera.main.orthographicSize, transform.position.z), 1f);
//down-left
Gizmos.color = Color.yellow;
Gizmos.DrawSphere(new Vector3((-Camera.main.orthographicSize) * Camera.main.aspect, -Camera.main.orthographicSize, transform.position.z), 1f);
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment