Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Serinx · Apr 16, 2018 at 04:04 AM · animationcolorcolor change

Animation to fade alpha but retain color

Is it possible to use an animation to fade the alpha channel on a material without affecting the colours?

I can remove the properties for R G B but as soon as I remove the A, the entire color property is removed.

I want to use this animation to fade out multiple objects of different colours, but they all inherit the colour of the animation.

I could do this via script, but was wondering if there is a way to do this using animation.

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 LandonC · Apr 16, 2018 at 04:33 AM 0
Share

I am a bit confused with your question, do you want to keep the rgb values of your object and change the alpha? or are you trying to change the rgb values and the alpha in the animation? If you are trying to change the alpha and rgb values of all your objects to the same value, wouldn't changing the rgba values already get the job done?

4 Replies

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

Answer by Serinx · Apr 17, 2018 at 06:43 AM

It appears that the animation cannot modify the existing color, it creates a new color and applies it to the object.

I decided to use a coroutine to fade out the alpha instead. Here's the code I used if anyone stumbles across this problem.

 StartCoroutine(fadeAlpha()); // Add this line in some other function e.g. Start()
 
     private IEnumerator fadeAlpha()
     {
         float duration = 1f;
         float startTime = Time.time;
         MeshRenderer[] renderers = gameObject.GetComponentsInChildren<MeshRenderer>();
         while (Time.time < startTime + duration)
         {
             foreach (MeshRenderer rend in renderers)
             {
                 Color clr = rend.material.color;
                 Color newColor = new Color(clr.r, clr.g, clr.b, clr.a - (Time.deltaTime / duration));
                 rend.material.SetColor("_Color", newColor);
             }
             yield return null;
         }
     }
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 LandonC · Apr 16, 2018 at 04:23 AM

If you are using the Animator component, just animate the color.a value without affecting the r, g, b values.

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 Serinx · Apr 17, 2018 at 03:36 AM 1
Share

When I record and change the alpha value in the inspector, it adds a property for all of the rgb values. I can remove 2 of them e.g. r and g but as soon as i remove the third (b) it also removes the alpha property.

avatar image LandonC Serinx · Apr 17, 2018 at 05:09 AM 0
Share

AH I see. I tried myself and was surprised! I have been using Animator component heavily and never had I made this happened.

Try this. When the record animation button is toggled, only change the alpha bar, the black to white gradient bar on the color panel. DO NOT SLIDE ON THE COLOR PIC$$anonymous$$ER, just the bar. You will get the alpha values keyed ins$$anonymous$$d of the RGB values.

avatar image Serinx LandonC · Apr 17, 2018 at 05:45 AM 0
Share

I managed to get only the alpha channel to display in the properties but now when it animates it is black, regardless of the initial colour of the object.

There are 2 objects. Ignore the emission - this has no impact on the issue.

alt text

avatar image
0

Answer by cobertos · May 04, 2020 at 12:28 AM

If you're using a custom shader, you might be able to add your own extra Vector1 property and just animate that instead

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 petremlabs · Jan 18, 2021 at 10:54 AM

You may try this:

In the Animation window, in the line where you change the Sprite Renderer Color property (if you're using Sprites), expand the property, and click on the small icon on the right of the rgb lines > Remove Property.

I think it should solve the issue.

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

212 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image

Related Questions

Can I make animations snap to a frame? 1 Answer

Button image sprite colour change 1 Answer

Partially recolor 2D sprites on either side of a line 0 Answers

Material color won't update! 2 Answers

How to constantly animate thousands of cubes 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