public void RemoveActor(FlexActor actor) { --m_actorCount; if (m_actorCount == 0) { DestroyContainer(); } }
public void AddActor(FlexActor actor) { if (m_actorCount == 0) { CreateContainer(); } ++m_actorCount; }
public void RemoveActor(FlexActor actor) { m_numParticles -= actor.asset.particles.Length; m_actors.Remove(actor); --m_actorCount; if (m_actorCount == 0) { DestroyContainer(); } }
public void AddActor(FlexActor actor) { if (m_actorCount == 0) { CreateContainer(); } actor.id = m_actorCount; ++m_actorCount; m_actors.Add(actor); m_numParticles += actor.asset.particles.Length; }
void OnFlexUpdate(FlexContainer.ParticleData _particleData) { FlexActor actor = GetComponent <FlexActor>(); if (actor is FlexSourceActor) { FlexSourceActor sourceActor = actor as FlexSourceActor; var main = m_particleSystem.main; float time = Time.time - Time.fixedTime; int[] indices = sourceActor.indices; int indexCount = sourceActor.indexCount; float[] ages = sourceActor.ages; m_particleSystem.Clear(); m_particleSystem.Emit(indices.Length); if (m_particles.Length != indexCount) { m_particles = new ParticleSystem.Particle[indexCount]; } float startLifetime = main.startLifetime.Evaluate(0); Color32 startColor = main.startColor.Evaluate(0); float startSize = main.startSize.Evaluate(0); for (int i = 0; i < indexCount; ++i) { ParticleSystem.Particle p = m_particles[i]; p.velocity = _particleData.GetVelocity(indices[i]);; p.position = (Vector3)_particleData.GetParticle(indices[i]) + p.velocity * (time - Time.fixedDeltaTime); p.remainingLifetime = ages[i] - time; p.startLifetime = startLifetime; p.startColor = startColor; p.startSize = startSize; m_particles[i] = p; } //m_particleSystem.SetParticles(m_particles, m_particles.Length); } else if (actor) { var main = m_particleSystem.main; float time = Time.time - Time.fixedTime; int[] indices = actor.indices; int indexCount = actor.indexCount; //m_particleSystem.Clear(); //m_particleSystem.Emit(indices.Length); if (m_particles.Length != indexCount) { m_particles = new ParticleSystem.Particle[indexCount]; } Color32 startColor = main.startColor.Evaluate(0); float startSize = main.startSize.Evaluate(0); for (int i = 0; i < indexCount; ++i) { ParticleSystem.Particle p = m_particles[i]; p.velocity = _particleData.GetVelocity(indices[i]); p.position = (Vector3)_particleData.GetParticle(indices[i]) + p.velocity * (time - Time.fixedDeltaTime); p.remainingLifetime = m_particleSystem.main.startLifetime.Evaluate(0); p.startLifetime = p.remainingLifetime; p.startColor = startColor; p.startSize = startSize; m_particles[i] = p; } //m_particleSystem.SetParticles(m_particles, m_particles.Length); } m_particleSystem.SetParticles(m_particles, m_particles.Length); }