Viewport ratio appears inconsistent in 2D game

I’ve been searching for a solution on this everywhere I can, so hopefully this isn’t a “duh” thing that was in the FAQ.

The problem is that the ViewPort’s handling of W over H are never consistent with the true/actual aspect ratio of my game assets. I am using the 2D workflow since this is a 2D game.

The reason I’m saying that it’s inconsistent is that my “background” image is 640 by 480 which is a ratio of H = 0.75 * W (4:3), yet in order to “trick” the viewport into displaying the correct way, I need to tell it to use W = 0.59 and H = 1.0 which is definitely not correct.

Nothing I’ve tried has been able to fix the issue. Furthermore, the viewport gets all messed up when actually running the game (becomes more like W=0.5 H=1.0), but that appears to be a separate issue.

I seemed to have solved the problem. After looking at some other posts, it seemed that ViewPort W and H are multiplied by the screen width and screen height, which would definitely explain the issues for me.

The problem is that the Inspector has no way to specify any alternative modes. Why the 2D workflow would not offer an alternative “absolute ratio” mode is beyond me, because the default mode does not work at all for “board game” type games. The fix required the following code in my start() handler… = new Rect(0, 0, (int)(Screen.height / 0.75), Screen.height);

I use 0.75 because I want a 4:3 ratio, but you would adjust this to whatever you need your ratio to be.

And then you’d want to just completely ignore what the ViewPort W and H get adjusted to as a consequence of the above code since board games don’t care about resolution-dependent-ratios. (it changed mine 0.59 to 0.5904335 since 0.59 was my approximation/workaround)