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 derrtyones · Sep 30, 2012 at 12:53 PM · javascripttextguistylefading

Fading a text gui style

Hi,

I'm showing a message on screen and I would like to fade that message out after 3 seconds.

I created a gui style.

 var myStyle : GUIStyle;
 static var showText : String = "Welcome";
 
 function OnGUI () {
     GUI.depth = 0;
     GUI.Label (Rect (Screen.width / 2 - 235, Screen.height - 40, 500, 50), showText, myStyle);
 }

This code displays the text "welcome" but how can I make it fade out within 5 seconds? Each time I google I get directed to the wiki page about fade.js but I am not sure if that's what I need. I tried using the fade.js but I don't understand how I can fade in/out my text with that.

Comment
Add comment · Show 1
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 AlucardJay · Sep 30, 2012 at 02:17 PM 1
Share

Check the examples here :

http://wiki.unity3d.com/index.php/Fade

http://wiki.unity3d.com/index.php/FadeIn

3 Replies

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

Answer by worldspawn · Sep 30, 2012 at 01:51 PM

The color of your text is stored in your GUIStyle myStyle, probably myStyle.normal.textColor. You could try changing the colors alpha component over time, that would be myStyle.normal.textColor.a

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 derrtyones · Sep 30, 2012 at 02:01 PM 0
Share

Could you give me a small example? I am not really sure what you mean.

avatar image
0

Answer by irdc · Feb 27, 2013 at 01:50 AM

Using your code above, you could do something like:

this.myStyle.normal.textColor.a = 255;

This will set the alpha (a) to 255, fully visible. If you want to change it over time, simply make the alpha value a variable and modify it in OnGUI().

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 drudiverse · Jun 19, 2014 at 07:13 PM 0
Share

that's almost right but it's wrong, 255 is .js, unity3d is 0-1 alpha

avatar image
0

Answer by drudiverse · Jun 19, 2014 at 07:14 PM

     var Label2:GUIStyle = new GUIStyle(GUI.skin.GetStyle("label"));
     Label2.fontSize = 22;
     Label2.normal.textColor =  Vector4(1,1,1,   0.3   ) ;
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

14 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

Related Questions

Javascript/Unityscript or c# String obfuscator ... 2 Answers

Problem with text from a .txt file. 1 Answer

How to make GUI Text appear after a certain amount of time 2 Answers

Gui Button Solid 2 Answers

Controlling text speed 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