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 Jim 4 · Sep 29, 2010 at 10:14 AM · graphicsguitexturealphaopacity

Changing opacity of a GUITexture element

Hi,

I'm very new to Unity, and am looking to 'pulse' (fade in & out repeatedly) a GUITexture or GUIText element.

Can anybody give me any pointers on how I might achieve this? Searched for answers here but couldn't find much.

Cheers

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

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by JoshOClock · Dec 17, 2010 at 10:00 PM

You want to change the Alpha of the Color.

http://unity3d.com/support/documentation/ScriptReference/Color-a.html

Using a sin wave the code would be something like this in c#:

void OnGUI()
{
    Color textureColor = guiTexture.color;
    textureColor.a = Mathf.Sin(Time.time * 5.0f);
    guiTexture.color = textureColor;
}

Just make the 5.0f higher for a faster rate.

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 Craftnime · Dec 07, 2015 at 05:12 AM 0
Share

Wouldn't GetComponent.<GUITexture>().color.a = someValue; work as well?

avatar image
0

Answer by Rasmus Schlnsen · Sep 29, 2010 at 10:27 AM

You should look into iTween. It's a very nice tweening library for Unity and you could use it for fading. There is even built in function for this. I'm linking to an answer I gave earlier. You can find it here

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 Jim 4 · Sep 29, 2010 at 11:10 AM 0
Share

Thanks for the quick response.

Having delved a bit further into Unity itself I've discovered the Animation View and the ability to animate position, alpha, rotation properties etc. using a timeline.

Co$$anonymous$$g from a Flash background this seems a bit more intuitive to me. Are you aware of any arguments against using the animation view?

avatar image pixelplacement · Oct 02, 2010 at 02:03 AM 0
Share

I have a 15 year background in Flash (and I'm the developer behind iTween) and all I can say is "whatever floats your boat". Neither approach is better or worse except that iTween and code based animation systems allow for quicker tweaking and control. Good luck.

avatar image
0

Answer by s4vi0r · Dec 17, 2010 at 09:43 PM

You could use interpolation.

Ex.

// Converts a white color to a black one trough time. var lerpedColor : Color = Color.white; function Update() { lerpedColor = Color.Lerp(Color.white, Color.black, Time.time); }

Take this idea now merge it with a guiTexture.color

function Update() { guiTexture.color = Color.Lerp(guiTexture.color, Color.red, Time.time); }

Another idea would be to use something like a sine wave. Might be even better option, since it would be infinite.

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

1 Person is following this question.

avatar image

Related Questions

Best way to change alpha on per object basis. (c#) 0 Answers

Drawing Sector around GameObject in GameView: GUITexture or 3D Object 1 Answer

transparent mode does not work at alpha=255 1 Answer

Changing opacity of a child object 1 Answer

(Health bar) Remove lives properly 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