Actually looks like a UI

Or is that an UI. Oh english you so funny sometimes. Not much to report today, except this video - in dire need of needing to actually look nice. It also scales with phone size (see below).

Turns out GUI doesn't scale with different resolutions. But no matter - maths saves the day:

float tx, ty, width, height, multiplier;
multiplier = (1 / baseScreenHeight) * Screen.height;
width = g.pixelInset.width * multiplier;
tx = g.pixelInset.x * multiplier;
ty = g.pixelInset.y * multiplier;
height = g.pixelInset.height * multiplier;
g.pixelInset = new Rect(tx, ty,

Basically it just takes the original resolution (baseScreenHeight) which is set as a constant equal to whatever you set as the screen height for testing (such as 480 in a 320x480 screen). Then it does maths and changes the PixelInset of the GUITexture to the new screen resolution. Yay.

There's also a whole bunch of other stuff to consider, but I won't go into that - read this article. Especially the bit about density independence.

No comments:

Post a Comment