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 Potzero · Mar 08, 2014 at 05:54 AM · colorfadelearningopacity

While fading object out, it turns black.

Hi everyone. Learning coder here. I have taken some sample code I've found around the forums and tried to implement a fade-in with a specified wait time first. The fade-in works, but the object is black. I have a feeling it has something to do with color.a, but I can't find what is wrong in the coding. Any help or fixed samples would be much appreciated. My code is below. Thanks.

 {
     public float waitTime = 3;
     float fadeSpeed = 0.01f;
     Color color;
 
     void Awake()
     {
         color.a = 0;
         renderer.material.color = color;
         StartCoroutine(WaitTime()); 
     }
 
     void Update()
     {
         if(color.a <= 1 && color.a > 0)
         {
             renderer.material.color = color;
             color.a += fadeSpeed;
         }
     }
     IEnumerator WaitTime ()
     {
         yield return new WaitForSeconds (waitTime);
         color.a += fadeSpeed;
     }
 }
 
Comment
Add comment · Show 4
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 Potzero · Mar 08, 2014 at 06:58 AM 0
Share

Thanks for the responses. The material is already transparency diffuse. If it matters, the material is a texture I made in photoshop. It has a white background, but disappeared when I put on the transparency diffuse shader. I inserted a line in Update() after color.a += fadeSpeed that states " renderer.material.color = Color.white; " but it turns the object white after its fully visible, as expected. The desired color is white.

avatar image highpockets · Mar 08, 2014 at 07:05 AM 0
Share

ok, is your texture a RGBA or just and RGB? It needs to be RGBA

avatar image Potzero · Mar 08, 2014 at 01:00 PM 0
Share

It is RGB. I figured out how to turn it to RGBA, however, since the object is 3D text, the text is no longer readable when I add the RGBA. Each letter in the text gets the texture and becomes a solid white rectangle.

avatar image highpockets · Mar 08, 2014 at 08:14 PM 0
Share

Ok, so you have made a texture for each letter, correct? Or you have a texture atlas?? Each letter texture would need to have a transparent background. I have never used it, but I believe 3D text just uses a transparent plane for each letter. Do you know the words that you are using?? And is that on your texture? Because if you know the words that you want and that will never change, than there is a much better and more optimized way of doing this.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by highpockets · Mar 08, 2014 at 06:11 AM

It needs a transparent shader. What kind of a shader is on it?

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 fifthknotch · Mar 08, 2014 at 06:11 AM 0
Share

Aw you beat me to it by 14 seconds...

avatar image highpockets · Mar 08, 2014 at 06:24 AM 0
Share

Not a race

avatar image
0

Answer by fifthknotch · Mar 08, 2014 at 06:11 AM

Your code works for me. Make sure the material of the GameObject this code is attached to is also set to Transparency => Diffuse

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

22 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

Related Questions

Fade out a line renderer? 1 Answer

Pull a color out of a Color.Lerp fade 1 Answer

Color lerp once? 2 Answers

How to change the alpha element of particles/additive color? 1 Answer

How to vertex colour a single instance of a GameObject? 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