【问题标题】:Unity 5.3 Setting Particle System Emission Rate not changingUnity 5.3 设置粒子系统发射率不变
【发布时间】:2016-06-28 01:44:54
【问题描述】:

我检查了文档,但没有发现如何更改我的粒子系统中的发射率,我检查了 Reddit 并没有发现任何东西。

这就是我想要改变的:

我认为可以使用的代码是这样的:

public ParticleSystem Smoke;


void Start()
{
    // Get the particle system (Smoke) Module.
    em = Smoke.emission;
    rate = em.rate;
    // Set the Mode to Constant.
    rate.mode = ParticleSystemCurveMode.Constant;

}

void Update()
{
    if (distance < 1f)
    {
        // Attempt to set the constant
        rate.constantMin = 20f;
        rate.constantMax = 20f;

    }
}

但是,当我在场景视图和检查器中查看我的 GameObjects Particle Systems Emission 时,使用上面的代码没有任何变化。我做错了什么?

【问题讨论】:

    标签: c# unity3d particle-system


    【解决方案1】:

    这在 5.3 中有点笨重。您必须获取速率并将其存储在局部变量中,更改您想要的值,然后设置它。

    void Update()
    {
        if(distance < 1f)
        {
            rate = em.rate;
            rate.constantMin = 20f;
            rate.constantMax = 20f;
            em.rate = rate;
        }
    }
    

    【讨论】:

    • HIGHFIVE 谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多