- Home /
Camera picture stretching when width changed in script?
When I reduce the size of the camera viewport width via script it causes the picture to stretch so that the same amount of the screen is still being displayed, as if the viewport were still full screen.
camMain.rect = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
However, if I change the width of the camera viewport via the Inspector, the picture is not stretched, it simply cuts off the left and right sides viewable area. This is the behavior I want.
How can I prevent showing the full scene with the objects stretched while still changing the camera width at runtime?
I've been working on this for hours with no progress. Any help would be appreciated. See attached picture for example. Left side is the problem, right side is what I'm expecting and needing.
Answer by yellowzelo · Sep 21, 2017 at 09:25 AM
This could help.
Camera.main.rect = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
Camera.main.ResetProjectionMatrix();