Unity

Unity ParticleSystem MainModule の duration 動的変更方法

パーティクルの duration をエディタから設定するだけでなく、スクリプトで動的に変更したい場合。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    private ParticleSystem ps;

    void Start()
    {
        ps = GetComponent();
        ps.Stop(); // Cannot set duration whilst Particle System is playing

        var main = ps.main;
        main.duration = 10.0f;

        ps.Play();
    }
}

-Unity
-

© 2024 yshystsj.com Powered by AFFINGER5