Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class MYCLASSNAME : MonoBehaviour {
float burstEnergy = 10.0f;
Transform explosionObject;
void LateUpdate (){
var theParticles= particleEmitter.particles;
var liveParticles= new int[theParticles.length];
var particlesToKeep= 0;
for (var i= 0; i < particleEmitter.particleCount; i++ )
{
if (theParticles[i].energy > burstEnergy)
{
theParticles[i].color = Color.yellow;
// We have so much energy, we must go boom
if (explosionObject)
Transform.Instantiate(explosionObject,
theParticles[i].position,
Quaternion.identity );
} else {
liveParticles[particlesToKeep++] = i;
}
}
// Copy the ones we keep to a new array
var = new Particle[particlesToKeep];
for (var j= 0; j < particlesToKeep; j++)
keepParticles[j] = theParticles[liveParticles[j]];
particleEmitter.particles = keepParticles;
}
}
using System.Collections;
public class MYCLASSNAME : MonoBehaviour {
float burstEnergy = 10.0f;
Transform explosionObject;
void LateUpdate (){
var theParticles= particleEmitter.particles;
var liveParticles= new int[theParticles.length];
var particlesToKeep= 0;
for (var i= 0; i < particleEmitter.particleCount; i++ )
{
if (theParticles[i].energy > burstEnergy)
{
theParticles[i].color = Color.yellow;
// We have so much energy, we must go boom
if (explosionObject)
Transform.Instantiate(explosionObject,
theParticles[i].position,
Quaternion.identity );
} else {
liveParticles[particlesToKeep++] = i;
}
}
// Copy the ones we keep to a new array
var = new Particle[particlesToKeep];
for (var j= 0; j < particlesToKeep; j++)
keepParticles[j] = theParticles[liveParticles[j]];
particleEmitter.particles = keepParticles;
}
}