- Home /
Skinned/unskinned GUI controls size differences
Hi
What's affect a control size when it has a skin applied?Because sizes of skinned and unskinned the same control are not equal Lets assue a situation:
I have a button described by rect (x,y,w,h),and I'd like to draw a box around it distanced by l each side.Then the box's rect shoud be defined like (x-l,y-l,w+2*l,h+2*l).
Well,above works as expected only if both button and box have no custom skin.When I apply my own,then suprisingly the button is larger than the box :O
Answer by MasterBLB · Jul 01, 2011 at 09:58 AM
Problem is solved-there was a border around inside graphics file.When I removed it all calculations give expected results.
Answer by Waz · Jun 30, 2011 at 01:50 PM
Surely this just means your skin has different settings for margin or padding for that control. That's the purpose of skinning - to change the size and content of controls.
It's not-I cleared all the padding/overflow/border/margin values to 0 in my skin
They're not 0 in the original though, hence the difference. border of 0 is very unlikely to be what you want.
Answer by GuyTidhar · Jun 30, 2011 at 01:58 PM
I presume this is due to padding/margin etc.
Notice that when you create a new GUIskin, each style, and specifically for your case - box and button styles have several definitions that change the way the viewable content of your object is painted by.
Look at the Padding, Border and Margin and notice they are different.
I suggest you have a look at what each of them does so you can play with it.
Check out guistyle: http://unity3d.com/support/documentation/ScriptReference/GUIStyle.html
That does not explain why sizes of skinned/unsinned are not the same.I ensured there are no 0 alpha border inside my graphics files,so I can expect when I wrote code:
if(GUI.Button(new Rect(xOffset,yOffset,285,62),"NEW CA$$anonymous$$PAIGN")); GUI.Box(new Rect(xOffset,Screen.height/2-62,285,62),"chui");
Sure,I can ovveride the size difference using padding/overflow,but since I can't use math to calculate exact control sizes such solution is worthless...
Well,I didn't tried layouts yet,maybe those will help
margin actually have only an effect on GUILayout elements since it's needed to specify the spacing between elements. The most important settings besides padding, border and overflow are fixedWidth, fixedHeight, stretchWidth, stretchHeight and contentOffset.
Your answer
Follow this Question
Related Questions
GUI Button selected changes color and stays until another button is clicked 1 Answer
Window Background Image not showing 1 Answer
GUI Button not working...but the the script is correct... 2 Answers
how big is my app size 2 Answers
Does removing scenes from build settings reduce the file size of a game? 2 Answers