Version: 2020.1
言語: 日本語

説明

OnParticleTrigger is called when any particles in a Particle System meet the conditions in the trigger module.

これは、衝突範囲の内側か外側にあるパーティクルを削除、または、修正するために使用されます。

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class TriggerScript : MonoBehaviour { void OnParticleTrigger() { ParticleSystem ps = GetComponent<ParticleSystem>();

// particles List<ParticleSystem.Particle> enter = new List<ParticleSystem.Particle>(); List<ParticleSystem.Particle> exit = new List<ParticleSystem.Particle>();

// get int numEnter = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter); int numExit = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Exit, exit);

// iterate for (int i = 0; i < numEnter; i++) { ParticleSystem.Particle p = enter[i]; p.startColor = new Color32(255, 0, 0, 255); enter[i] = p; } for (int i = 0; i < numExit; i++) { ParticleSystem.Particle p = exit[i]; p.startColor = new Color32(0, 255, 0, 255); exit[i] = p; }

// set ps.SetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter); ps.SetTriggerParticles(ParticleSystemTriggerEventType.Exit, exit); } }

In order to retrieve detailed information about all the collisions caused by the ParticleSystem, ParticlePhysicsExtensions.GetTriggerParticles must be used to retrieve the array of Particle.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961