• 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 Matti Jalopeura · Oct 26, 2010 at 03:32 PM · hudiconglow

How to make a glowing icon on a HUD?

Hi,

I'm trying to make an icon on my HUD glow like a warning sign. A sine wave would be very good, but I have no idea how to implement one. Right now I'm using GUI.DrawTexture.

Thank you.

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

4 Replies

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

Answer by burnumd · Oct 26, 2010 at 05:06 PM

Look at both GUI.color and Mathf.PingPong. You can change the alpha of the GUI color with something along the lines of

GUI.color.a = Mathf.PingPong (Time.time, 1);

just before you call GUI.DrawTexture. If you want to have a minimum opacity higher than 0, though, you'll have to write your own PingPong function.

When you've drawn your texture set

GUI.color.a = 1;

Note that direct modification to Color.a only works in Javascript-flavored scripting. If you're working in C#, you'll have to do something like

GUI.color = new Color (GUI.color.r, GUI.color.g, GUI.color.b, 1);
Comment
Add comment · Show 2 · 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 Matti Jalopeura · Oct 26, 2010 at 09:09 PM 0
Share

Thank you, that helped a lot. Now I just need to find out how to get information from my C# scripts to this Javascript.

avatar image burnumd · Oct 29, 2010 at 02:00 PM 0
Share

If you're working in C#, the approach still works, you just can't modify ".a" with colors directly. You'd need to do something like GUI.color = new Color (GUI.color.r, GUI.color.g, GUI.color.b, 1); I'll edit my post because I realize now I said "Access" when I should have said "$$anonymous$$odify." Sorry for the confusuion.

avatar image
0

Answer by AVividLight · Oct 26, 2010 at 03:36 PM

Make a image in Photoshop (Or whatever) and then add it to Unity...

Comment
Add comment · Show 2 · 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 xeophin · Oct 26, 2010 at 04:29 PM 0
Share

I guess he means that he wants it to look like it's pulsating?

avatar image AVividLight · Oct 26, 2010 at 06:09 PM 0
Share

Yeah, using frame by frame animation, that would be easy...

avatar image
0

Answer by xeophin · Oct 26, 2010 at 04:39 PM

Since there seems no way to change the opacity of a GUITexture (someone correct me if I'm wrong), you won't be able to make it glow by changing the opacity.

Therefore I assume that the only way to achieve a pulsating effect would be to produce a series of images with the changing glow and cycle through them.

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
0

Answer by noradninja · Oct 27, 2010 at 11:18 PM

You can change a GUITexture opacity over time by altering

GUITexture.color.a

For example:

function AnimateGUITextureOpacity (start : float, end : float, length : float, target : GUITexture) {

for (i = 0.0; i < 1.0; i += Time.deltaTime*(1/length)) { //for the length of time

target.color.a = Mathf.Lerp(start, end, i); //lerp the value of the transparency from the start value to the end value in equal increments yield; target.color.a = end; // ensure the fade is completely finished } //end for

} //end function

will lerp the opacity of a GUITexture over time with a start and end value and speed you define as well as the specific GUITexture you want it to apply to.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Minimap blib icon error 1 Answer

Custom icons for custom Monobehaviours in custom namespaces 1 Answer

App Icon Lost on Commit 0 Answers

App Icon / Splashscreen on Hololens 2 1 Answer

how to rotate GUI Textures 5 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