Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 DziekDB · Jul 31, 2013 at 07:20 PM · guiguistylefontsize

GUIStyle applying to all labels, even after I comment it out.

Hey, so I made a style to change font size, but it changes the font size of every label.

Worse, when I comment out the style in my script every thing stays changed, and I have to close and re-open Unity for the labels to reset to normal size.

 function OnGUI ()
 {
     if ((PlayState == PlayStates.Splash)){
         GUI.Label (Rect(300,20,1000,200),"Press Space to Play");
     }
     if ((PlayState == PlayStates.End)){
         GUI.Label (Rect(300,20,1000,200),"Press Space to Play Again");
     }
     
     GUI.Label (Rect(300,40,1000,200),
     "Round 1: " + round[0] + " Round 2: " + round[1]+ " Round 3: " + round[2]+ " Round 4: " + round[3]+ " Round 5: " + round[4]);
     
     if ((PlayState == PlayStates.Splash)){
         GUI.Label (Rect(605,20,1000,200),"Hold I to display Instructions");
     }
     
     var bigFont:GUIStyle = "label";
     bigFont.fontSize = 30;
     
     var timeRemainingString = timeRemaining.ToString("F2");
     GUI.Label (Rect(300,90,1000,200), timeRemainingString, bigFont);
 
 }
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

1 Reply

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

Answer by perchik · Jul 31, 2013 at 07:23 PM

I'm not as familiar with Javascript, but I have a hunch at what's going on.

When you get the GUIStyle (` var bigFont:GUIStyle = "label";`) I assume that gets the default Label style, which actually changes the default values.

What you need to do is pass in a new GUIStyle that you want to use (from the editor). Then manipulating that GUIStyle won't affect everything, just anything that uses that style

Comment
Add comment · Show 1 · 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 DziekDB · Jul 31, 2013 at 07:39 PM 0
Share

It was exactly that!

Just had to change it to this:

 var skin = GUI.skin;
     var bigFont:GUIStyle = GUIStyle(skin.GetStyle("label"));
     bigFont.fontSize = 300;

Thanks!

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do i change the fontSize of a displayed message? 1 Answer

Using GUISkin with Hierachy Objects 0 Answers

Using a custom style of GUI.skin 3 Answers

Hover state doesn't work on slider with custom styles 0 Answers

Change GUI.Box color when click button 1 Answer


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