美文网首页
unity改变物体透明度

unity改变物体透明度

作者: 沉麟 | 来源:发表于2018-12-03 17:57 被阅读0次

点击shader--“Legacy Shaders”--“Transparent”--“Diffuse”
让物体显示2秒,之后逐渐淡出视野。

IEnumerator BrakerDestory(GameObject obj)
    {
        yield return new WaitForSeconds(2);
        float brakeTime = 0.5f;
        while (brakeTime > 0.05f)
        {
            brakeTime -= Time.deltaTime;
            obj.transform.GetComponent<Renderer>().material.color = new Color(0.2f, 0.2f, 0.2f, brakeTime);
            yield return null;
        }

        yield return null;

    }

相关文章

网友评论

      本文标题:unity改变物体透明度

      本文链接:https://www.haomeiwen.com/subject/tchucqtx.html