如何使用标准着色器在 GameObject 上淡化 alpha?

How to fade alpha on GameObject using Standard Shader?

如何简单地淡出应用了标准着色器的游戏对象?

这是我的代码。如果我将着色器切换为 Sprites.default 它会起作用。

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);
}

确保您在 material.

上将标准着色器的类型设置为 "Fade" 或 "Transparent"