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 robertmathew · Apr 13, 2011 at 08:23 AM · guibuttonglow

glowing gui button

i want to create a GUI.Button.

my need is i want to fade in and out the color of Gui.Button with out fading the text inside the gui.button.

i do not want the gui.button to fade.

i want the color inside the gui button should fade in and out like indicator(like traffic light)

i tried with making alpha content a = 0; this if fadding the button itself.i just want the color inside the gui button to fade and fade out

function OnGUI() { GUI.backgroundColor.a = Mathf.Lerp(1.0, 0.0,Time.time*0.1); if(GUI.Button(new Rect(Screen.width *(4.1/6.55), Screen.height*(0.8/6.55),Screen.width*(.4/6.55),Screen.height * (.2/6.55)),"")) {

      }

      }

i tried this code this fading gui button text along with gui button color.i want text return in the button should not fade along with the color

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
Best Answer

Answer by marceloroca · Apr 13, 2011 at 12:00 PM

add a label with the same position and set the alpha channel to 1

function OnGUI() { var rect = new Rect(Screen.width *(4.1/6.55), Screen.height*(0.8/6.55),Screen.width*(.4/6.55),Screen.height * (.2/6.55)); GUI.backgroundColor.a = Mathf.Lerp(1.0, 0.0,Time.time*0.1); if(GUI.Button(rect,"")) { Debug.Log("click"); }

 GUI.backgroundColor.a = 1;
 GUI.Label(rect,"Button");

}

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
2

Answer by TheDemiurge · Apr 13, 2011 at 10:58 AM

GUI.backgroundColor is your answer, I think. for Javascript GUI.backgroundColor.a = ... and for C# GUI.backgroundColor = new Color(r, g, b, a); (or store it before, so you're not using new in OnGUI code)

Comment
Add comment · Show 3 · 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 robertmathew · Apr 13, 2011 at 11:08 AM 0
Share

how to get the effect suppose my button is blue color i want the blue color to fade in and out with out fading the text inside the button. i tried this code GUI.backgroundColor.a = $$anonymous$$athf.Lerp(1.0, 0.0,Time.time*0.1); it is fading the the text along with the gui button color

avatar image TheDemiurge · Apr 13, 2011 at 12:16 PM 0
Share

Not sure what to say. I threw only the first two lines into an OnGUI function and it worked. Then I threw in the bit with the Lerp just to test and... it's keeping the text there while changing the alpha of the button itself. Your button isn't saying anything right now but the color fading should still work..

avatar image TheDemiurge · Apr 13, 2011 at 12:18 PM 0
Share

Try something like GUI.backgroundColor = Color(0, 0, 1, $$anonymous$$athf.Lerp(1, 0, Time.time*0.1)); for the heck of it - see if that makes a difference. Not sure what to say otherwise.

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

No one has followed this question yet.

Related Questions

How to make GUI button glow 0 Answers

Button Turns Off and On Object 1 Answer

Button then instanitates gameobject 1 Answer

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

Make more buttons appear, on button click. 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