Esempio n. 1
0
        public void OnValidate(UnityEngine.ParticleSystem particleSystem)
        {
            if (this.hasDefault == false)
            {
                this.settings   = ParticleSimulationSettings.@default;
                this.hasDefault = true;
            }

            this.particleItem = new ParticleSimulationItem();
            this.particleItem.particleSystem = particleSystem;
        }
Esempio n. 2
0
        public void SimulateParticles(float time, uint seed, ParticleSimulationSettings settings)
        {
            this.particleSystem.Stop(true, UnityEngine.ParticleSystemStopBehavior.StopEmittingAndClear);
            if (this.particleSystem.useAutoRandomSeed == true)
            {
                this.particleSystem.useAutoRandomSeed = false;
            }
            if (this.particleSystem.randomSeed != seed)
            {
                this.particleSystem.randomSeed = seed;
            }

            if (settings.simulationType == ParticleSimulationSettings.SimulationType.RestoreSoft)
            {
                if (time > settings.minSimulationTime)
                {
                    var mainModule = this.particleSystem.main;
                    var duration   = mainModule.duration / mainModule.simulationSpeed;
                    var halfEnding = (duration - time) * settings.halfEnding;
                    if (halfEnding <= settings.minEndingTime)   // if ending is less than Xms - skip

                    {
                        this.Reset();
                        return;
                    }

                    this.simulateToTime         = time + halfEnding;
                    this.currentTime            = 0f;
                    this.simulateToTimeDuration = halfEnding;

                    this.Simulate(this.simulateToTime);
                    if (this.customLifetime == false && this.particleSystem.particleCount <= 0)
                    {
                        this.Reset();
                    }

                    this.Simulate(0f);
                }
                else
                {
                    this.Simulate(time);
                }
            }
            else if (settings.simulationType == ParticleSimulationSettings.SimulationType.RestoreHard)
            {
                this.Simulate(time);
            }
            else if (settings.simulationType == ParticleSimulationSettings.SimulationType.NoRestore)
            {
                this.Simulate(0f);
            }
        }
Esempio n. 3
0
        public void OnValidate(UnityEngine.ParticleSystem[] particleSystems)
        {
            if (this.particleItems == null || this.particleItems.Length != particleSystems.Length)
            {
                if (this.hasDefault == false)
                {
                    this.settings   = ParticleSimulationSettings.@default;
                    this.hasDefault = true;
                }

                this.particleItems = new ParticleSimulationItem[particleSystems.Length];
                for (int i = 0; i < this.particleItems.Length; ++i)
                {
                    this.particleItems[i] = new ParticleSimulationItem();
                    this.particleItems[i].particleSystem = particleSystems[i];
                }
            }
        }
Esempio n. 4
0
        public bool Update(float deltaTime, ParticleSimulationSettings settings)
        {
            if (settings.simulationType == ParticleSimulationSettings.SimulationType.RestoreSoft && this.simulateToTimeDuration > 0f)
            {
                this.currentTime += deltaTime / this.simulateToTimeDuration;
                if (this.currentTime <= 1f)
                {
                    this.Simulate(this.currentTime * this.simulateToTime);
                }
                else
                {
                    this.Reset();
                }

                return(true);
            }

            return(false);
        }