Version: 2019.2
public bool enabled ;

説明

Color Over Lifetime モジュールの有効/無効を切り替えます。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public float hSliderValue = 1.0f;

void Start() { ps = GetComponent<ParticleSystem>();

var colorOverLifetime = ps.colorOverLifetime; colorOverLifetime.enabled = true;

Gradient gradient = new Gradient(); gradient.SetKeys( new GradientColorKey[] { new GradientColorKey(Color.green, 0.0f), new GradientColorKey(Color.red, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(1.0f, 1.0f) } );

colorOverLifetime.color = new ParticleSystem.MinMaxGradient(gradient); }

void Update() { var main = ps.main; main.startLifetime = hSliderValue; }

void OnGUI() { hSliderValue = GUI.HorizontalSlider(new Rect(25, 45, 100, 30), hSliderValue, 1.0f, 5.0f); } }