美文网首页
动态设置Unity粒子发射速率

动态设置Unity粒子发射速率

作者: 白九a | 来源:发表于2016-12-30 14:18 被阅读0次
    //错误写法
    void SetEmissionRate (GameObject pGo, float pValue)
    {
        ParticleSystem tParticleSystem = pGo.GetComponentInChildren<ParticleSystem> ();
        tParticleSystem.emission.rate = new ParticleSystem.MinMaxCurve (pValue);
    }

上述写法编译报错。

    //正确写法
    void SetEmissionRate (GameObject pGo, float pValue)
    {
        ParticleSystem tParticleSystem = pGo.GetComponentInChildren<ParticleSystem> ();
        ParticleSystem.EmissionModule emission = tParticleSystem.emission;
        emission.rate = new ParticleSystem.MinMaxCurve (pValue);
    }

面板中数值没有变,但实际执行效果已经修改

参考

粒子系统模块 – 问答

相关文章

网友评论

      本文标题:动态设置Unity粒子发射速率

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