示例#1
0
        public static void BuildMessage(InputParticleMessage message)
        {
            if (particleSystems != null)
            {
                foreach (ParticleSystem particleSystem in particleSystems)
                {
                    if (particleSystem.isPlaying)
                    {
                        float deltaTime = particleSystem.time - lastParticleTime;
                        if (deltaTime < 0)
                        {
                            deltaTime = particleSystem.time - lastParticleTime + particleSystem.main.duration;
                        }
                        message.particleDeltaTime = deltaTime;

                        lastParticleTime = particleSystem.time;
                        break;
                    }
                }
            }
        }
示例#2
0
        public static void ProcessMessage(InputParticleMessage message)
        {
            if (particleSystems != null && particleSystems.Length > 0)
            {
                foreach (ParticleSystem particleSystem in particleSystems)
                {
                    if (target.ContainsKey(particleSystem))
                    {
                        target[particleSystem] = (message.particleDeltaTime + target[particleSystem]) % particleSystem.main.duration;

                        float deltaTime = target[particleSystem] - particleSystem.time;
                        if (deltaTime < -particleSystem.main.duration + 1)
                        {
                            deltaTime += particleSystem.main.duration;
                        }
                        if (deltaTime > 0 && deltaTime < 1)
                        {
                            particleSystem.Simulate(deltaTime, true, firstSyncTime);
                        }
                    }
                }
                firstSyncTime = false;
            }
        }