Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 JoshMBeyer · Nov 05, 2014 at 11:04 PM · guifadegui.labelinout

How to fade in GUI text.

So I have a few GUI.Label, and a few GUI.Styles to go with them. Since there are a few different ones to each there own settings. So how can I fade these labels in? I know the most simple way is to adjust the alpha. I did this before on fading a character renderer. I tried this with the text and the alpha isn't accessing anything. Saying used as a property but can't because its a type. Can someone write a simple line of code to show me how to do this correctly please?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by podmaster · Nov 06, 2014 at 12:47 AM

Sorry i have updated my unity to the new UI 4.6 so i don't remember exactly how to do it but you should first get the Gui text component then acces the color alpha.

 var GuiLabel : GUIText;
 
 GuiLabel.color.a = yourValue;
 
 //OR
 
 SomeGameObject.GetComponent(GUIText).color.a = yourValue;


If you are getting an error post it and post your code.

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 JoshMBeyer · Nov 06, 2014 at 06:19 AM 0
Share

its not a gui text component. its a scripted GUI.Label

avatar image
0

Answer by Ozzyel-PT · Nov 06, 2014 at 06:30 AM

 public float alpha = 1.0f;
 public float fadeSpeed = 2.0f;
 void OnGUI()
 {
 
         if(GUI.Button(new Rect(Screen.width/2, Screen.Height/2, 200, 50))
          {
            StartCoroutine(Fade());
          }
         GUI.color = new Color(255, 255, 255, alpha);// adjust alpha value
         GUI.Label(new Rect(0, 0, 200, 50), "Label");
         //All elements to fade
         GUI.color = new Color(255, 255, 255, 1); // sets it back to 1 for another elements
 }
 IEnumerator Fade()
 {
     alpha = 0;
     while (alpha < 1f)
     {
         alpha += Time.deltaTime*fadeSpeed;
         yield return null;
     }
 }
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

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

28 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Easy fade in/out on level load/end? 2 Answers

Fade In and out when level is loaded 2 Answers

Fade 3d text with lerp? 1 Answer

fade in out multi images then go to next scene 1 Answer

Transitions When Pausing? 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