Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Aeleas

color.a value not changing ?

Question

My script is about an object, If i get close color.a disable.image.png

 

Please login or register to see this code.

but it never change or update ?

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 1

Don't forget to apply the new Color on your object. This one works with a standard material, but Fade or Transparency. Tested ++

 

Please login or register to see this code.
  • Like 1

Share this post


Link to post
Share on other sites

  • 0

You need to set the color again to the material.

Please login or register to see this code.

Not sure if a Color32 works in this case tho, but you could always use a normal Color. Just divide by 255 so it ranges from 0 to 1.

Share this post


Link to post
Share on other sites
  • 0

Change to a different material that supports transparency ++

Share this post


Link to post
Share on other sites
  • 0

I think the alpha value is clamped to 0-1 in unity. So for example, if you want to see the object:

  • 100% -- object_color.a = 1f;
  • 50% -- object_color.a = 0.5f;
  • 0% -- object_color.a = 0f;

Share this post


Link to post
Share on other sites
  • 0

roland is correct. Color values are a float between 1 and 0. So just change 1 to 0 and 255 to 1

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

For Color that is true, Color32 goes from 0 to 255 though

Share this post


Link to post
Share on other sites
  • 0

Thank you guys for you replies.

I tried all what you wrote and nothing change.

I'm using only material without texture.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...