2D camera positioning in Unity and & size
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);
    
    } 

0 comments:

Post a Comment

Pin ThisShare on TumblrShare on Google PlusEmail This
 
Top