// Lerp to state object public static void Lerp (PlaygroundParticlesC playgroundParticles, ParticleStateC state, float time, LERPTYPEC lerpType) { if(time<0) time = 0f; Color color = new Color(); for (int i = 0; i<playgroundParticles.particleCache.Length; i++) { if (lerpType==LERPTYPEC.PositionColor||lerpType==LERPTYPEC.Position) playgroundParticles.particleCache[i].position = Vector3.Lerp(playgroundParticles.particleCache[i].position, state.GetPosition(i%state.positionLength), time); if (lerpType==LERPTYPEC.PositionColor||lerpType==LERPTYPEC.Color) { color = state.GetColor(i%state.colorLength); playgroundParticles.particleCache[i].color = Color.Lerp(playgroundParticles.particleCache[i].color, color, time); } } }
// Lerp to specified state in this PlaygroundParticles public static void Lerp (PlaygroundParticlesC playgroundParticles, int to, float time, LERPTYPEC lerpType) { if (to<0) {to=playgroundParticles.states.Count;} to=to%playgroundParticles.states.Count; if(time<0) time = 0f; Color color = new Color(); for (int i = 0; i<playgroundParticles.particleCache.Length; i++) { if (lerpType==LERPTYPEC.PositionColor||lerpType==LERPTYPEC.Position) playgroundParticles.particleCache[i].position = Vector3.Lerp(playgroundParticles.particleCache[i].position, playgroundParticles.states[to].GetPosition(i%playgroundParticles.states[to].positionLength), time); if (lerpType==LERPTYPEC.PositionColor||lerpType==LERPTYPEC.Color) { color = playgroundParticles.states[to].GetColor(i%playgroundParticles.states[to].colorLength); playgroundParticles.particleCache[i].color = Color.Lerp(playgroundParticles.particleCache[i].color, color, time); } } Update(playgroundParticles); }