I’m drawing a button with GUI.Button and a custom GUI style, but I’m also making the game resolution and aspect-ratio independent so the GUIRect varies considerably in both scale and aspect. If I use the same texture and rect with GUI.DrawTexture the shape is drawn correctly, but with GUI.Button the button is drawn the wrong shape.
Now there are quite a lot of options with GUIStyles but I’ve been through all the ones that seem vaguely relevant and none of them seem to stop Unity from ignoring my Rect.
My Padding, Border, Margin and Overflow are all zero, so it’s not them. Stretch Width and Stretch Height are both disabled, so that Unity does not stretch horizontally or vertically “for a better layout”. Additionally, fixed width and fixed height are both set to zero to stop Unity from trying to “override any provided Rect() value” but still it is not using the Rect properly.
So essentially, this draws correctly:
//GUI.DrawTexture(TrinityDialExamineDrawRect, TrinityDialExamineTexture);
And this draws incorrectly:
GUI.Button(TrinityDialExamineDrawRect, TrinityDialExamineTexture, TrinityButtonStyle)
It’s almost as though Unity is refusing to use the full width of the rect available to it, to draw my image, but with zero set for border, padding, margin and overflow, I can’t imagine why that would be.
EDIT: Sorry, I missed one. Content offset is set to zero as well.