Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MasterBLB · Jun 30, 2011 at 01:42 PM · guisizeskin

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MasterBLB · Jun 30, 2011 at 01:52 PM 0
Share

It's not-I cleared all the padding/overflow/border/margin values to 0 in my skin

avatar image Waz · Jun 30, 2011 at 02:28 PM 1
Share

They're not 0 in the original though, hence the difference. border of 0 is very unlikely to be what you want.

avatar image
0

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MasterBLB · Jun 30, 2011 at 03:19 PM 0
Share

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

avatar image Bunny83 · Jun 30, 2011 at 07:16 PM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges