0

How to simply fade a game object that has a Standard shader applied?

This is my code. If I switch the shader to Sprites.default it works.

public void foo(float val)
{
     _isFade=true;
     float time=2.0f;
     float alphaVal=0.0f;
     LeanTween.alpha(gameObject, alphaVal, time);

     Debug.Log("YES calling fade in foo !!!! and gameObject = "+gameObject);
}
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Bachalo
  • 6,965
  • 27
  • 95
  • 189

1 Answers1

1

Make sure that you have the type of the Standard shader set as "Fade" or "Transparent" on your material.

EvilTak
  • 7,091
  • 27
  • 36
  • 1
    works using Fade but now my objects seem transparent and they should be opaque. Z buffer issue? – Bachalo Jun 25 '15 at 11:29
  • If you want to "fade" the object, that means transparency isn't it? If you want the object to have like a Glass like look then use Transparent. If you slowly want to make the object dissapear or something like that use Fade. Refer to [this link](http://docs.unity3d.com/Manual/StandardShaderMaterialParameters.html) and go under the Rendering Modes section for more info. – EvilTak Jun 25 '15 at 13:48
  • not sure you read my comment. I have a common problem with Fade causing Z buffer issues, ie objects aren't layered properly and appear transparent. Will post my solution tomorrow – Bachalo Jun 25 '15 at 21:24