Search code examples
unity-game-enginemonodevelop

How can I change plane size with different screen resolution?


Is there any way I could fixed the screen resolution? I mean if it played at 800x480,800x600, 1280x1024, 1280x720, or wide screen, the camera keep showing same scene, same height and same width. Maybe by making the object bigger, or else.

Regards Kajal


Solution

  • try this.this one is for perspective camera.hope it will work.

        Camera cam = Camera.main;
    
        float pos = (cam.nearClipPlane + 10.0f);
    
        transform.position = cam.transform.position + cam.transform.forward * pos;
        transform.LookAt (cam.transform);
        transform.Rotate (90.0f, 0.0f, 0.0f);
    
        float h = (Mathf.Tan(cam.fov*Mathf.Deg2Rad*0.5f)*pos*2f) /10.0f;
    
        transform.localScale = new Vector3(h*cam.aspect,1.0f, h);