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
1
Question by user-1846 (google) · May 22, 2010 at 02:45 PM · animationguimovementfadelogin

Fade In/Out Login GUI?

Hello!

I was wondering - has anybody figured out how to literally fade on a GUI? I really need this for my login script....

Seems obvious don't it?

Thanks! Christian Stewart

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 equalsequals · May 22, 2010 at 04:52 PM 1
Share

Do you mean a GUITexture or a texture drawn using Unity GUI?

1 Reply

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

Answer by equalsequals · May 22, 2010 at 05:23 PM

To fade a GUITexture object:

public class FadeTexture : MonoBehaviour {

private GUITexture gt; private float _alpha = 1F; private bool fadeIn = false;

// Use this for initialization void Start () { gt = (GUITexture) gameObject.GetComponent(typeof(GUITexture));

}

// Update is called once per frame void Update () { print(_alpha);

 if(fadeIn)
 {
     _alpha = Mathf.Lerp(_alpha, 1F, Time.deltaTime);
     gt.color = new Color(.5F,.5F,.5F,_alpha);
     if(_alpha > .98F) fadeIn = false;
 }
 else
 {
     _alpha = Mathf.Lerp(_alpha, 0F, Time.deltaTime);
     gt.color = new Color(.5F,.5F,.5F,_alpha);
     if(_alpha < .01F) fadeIn = true;
 }                   

}

Just apply that script to a Game Object that has a GUITexture component and it'll fade in and out. Modify it to do whatever you need it to do. I'd suggest possibly wrapping the fade inside of a coroutine instead of Update.

[Edit]

To do something similar with OnGUI(), add this to the above code:

void OnGUI() { GUI.color = new Color(.5F,.5F,.5F,_alpha); GUI.TextField(new Rect(0,0,300,30), "This will fade.");

 GUI.color = new Color(.5F,.5F,.5F,1F);
 GUI.TextField(new Rect(0,80,300,30), "This will not.");

}

Also take a look at the other 2 properties that are similar to GUI.color in the docs to isolate more specific parts of your GUI. Since OnGUI is immediate mode and procedural you can see that just redefining the color property later on in the script will produce different results in the same pass.

Hope that helps.

==

Comment
Add comment · Show 6 · 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 user-1846 (google) · May 22, 2010 at 05:36 PM 0
Share

Thanks, but I meant GUI created with the GUI class in scripting. This is great, thanks for the help, but its not exactly what I needed... Thanks though for the help!

avatar image user-1846 (google) · May 22, 2010 at 05:37 PM 0
Share

GUI meaning like text boxes and buttons :)

avatar image equalsequals · May 22, 2010 at 06:17 PM 0
Share

Ah I see, thats a misunderstanding due to lexicon. I'll post another answer.

avatar image equalsequals · May 22, 2010 at 06:18 PM 0
Share

On second thought I'll just revise my previous answer. Cheers.

avatar image amir_bobo · Jun 27, 2011 at 07:33 AM 0
Share

Very Nice man!

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Who Killed Who - Scrolling GUI Text 2 Answers

Play one animation and rewind another 0 Answers

How to hook up the particle system to jump animation? 1 Answer

Getting animations to play relative to player's direction? 4 Answers

Change animation of 4 Way Movement Sprites moving diagonally to last used non-diagonal direction? 0 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