make a mesRenderer fadeIn and fadeOut after time using c#?
Hi, I'm an animator and pretty new to c# and coding language here. I want to make:
A meshRenderer fadeIn in duration right at startTime (ie when i press a button)
Then after a delayDuration from startTime, do a fadeOut in anotherDuration
I've searched and be able to do a fadeIn and fadeOut after delayDuration separatedly (by follow the answer in this question and by adding a waitForSeconds)
but stuck at combining both of them together.   Very appreciate if someone can help.
Thank you.
               Comment
              
 
               
              Answer by raaan127 · May 15, 2020 at 10:48 AM
Hi, With help from my friend, I finally can do this using DOTween (free from asset store)
 void TxtAnim(float delayFadeIn, float delayFadeOut, float fadeInDuration, float **fadeOutDuration**)
 {
     _meshRenderer.material.DOColor(Color.white, fadeInDuration).SetDelay(delayFadeIn).OnComplete(() =>
     {
         _meshRenderer.material.DOColor(Color.clear, fadeOutDuration).SetDelay(delayFadeOut).OnComplete(() =>
         {
             Destroy(gameObject);
         });
     });
 }
 
              Your answer