// RESET EMITTER DATA // // public void ResetEmitterData() { emitterTime = 0; nonZeroParticleCountTime = 0; emitterLoopTime = 0; smoothDeltaTime = 0; emitterAcceleration = Vector3.zero; emitterVelocity = Vector3.zero; emitterPosition = transform.position; emitterRotation = transform.rotation.eulerAngles; emitterScale = transform.lossyScale; exampleInputParticleIndex = -1; System.Random theRandom = new System.Random(); randomSeed = theRandom.Next(65535); spawnRateAccumulator = 0; newParticleIndices = new List <int>(); emitterModule = blueprint.emitterStack.modules[0] as BaseEmitterModule; isPlaying = emitterModule.playOnAwake.GetValue(); wasPlaying = false; isStopped = isPlaying == false; isPaused = false; wasPaused = false; isLooping = emitterModule.isLooping.GetValue(); UpdateCurrentTime(); prevTime = currentTime; lastRenderTime = currentTime; int maxParticleNumber = (int)emitterModule.maxParticles.GetValue(); particleMarkers = new Pool <ParticleMarker>(maxParticleNumber); particleIds = new int[maxParticleNumber]; particleTimes = new float[maxParticleNumber]; particleDyingTimes = new float[maxParticleNumber]; accelerationAccumulators = new Vector3[maxParticleNumber]; velocityAccumulators = new Vector3[maxParticleNumber]; rotationRateAccumulators = new Vector3[maxParticleNumber]; travelDistances = new float[maxParticleNumber]; collisionTimes = new float[maxParticleNumber]; isEmitterDataReset = true; }
// HANDLE BLUEPRINT CHANGE // // public void HandleBlueprintChange() { if (blueprint != null) { blueprint.ownerEmitter = this; selectedStack = blueprint.emitterStack; emitterModule = blueprint.emitterStack.modules[0] as BaseEmitterModule; #if UNITY_EDITOR UpdateSharedPropertyList(); #endif } else { selectedStack = null; emitterModule = null; } #if UNITY_EDITOR previousBlueprint = blueprint; #endif SoftReset(); }
public AmpsEmitter ownerEmitter; // The AmpsEmitter component using this instance of the asset. #if UNITY_EDITOR // INITIALIZE // // public void Initialize() { if (stacks == null) { stacks = new List <BaseStack>(); } else { stacks.Clear(); } // First of all we fully set up the emitter's core parts. emitterStack = new VoidStack(); emitterStack.Initialize(this, AmpsHelpers.eStackFunction.Emitter, typeof(BaseEmitterModule).ToString()); stacks.Add(emitterStack); if (emitterStack.modules.Count == 0) { BaseEmitterModule em = ScriptableObject.CreateInstance <BaseEmitterModule>(); em.Initialize(emitterStack, this); em.playOnAwake.value = true; em.isLooping.value = true; em.maxParticles.constant = 10; em.moduleName.value = "Basic emitter properties"; emitterStack.modules.Add(em); emitterStack.selectedModule = em; } renderStack = new VoidStack(); renderStack.Initialize(this, AmpsHelpers.eStackFunction.Render, typeof(BaseRenderModule).ToString()); stacks.Add(renderStack); sharedStack = new VoidStack(); sharedStack.Initialize(this, AmpsHelpers.eStackFunction.Shared, typeof(BaseGenericModule).ToString()); stacks.Add(sharedStack); spawnRateStack = new FloatStack(); spawnRateStack.Initialize(this, AmpsHelpers.eStackFunction.SpawnRate, typeof(BaseGenericModule).ToString()); stacks.Add(spawnRateStack); deathConditionStack = new FloatArrayStack(); deathConditionStack.Initialize(this, AmpsHelpers.eStackFunction.DeathCondition, typeof(BaseGenericModule).ToString()); stacks.Add(deathConditionStack); deathDurationStack = new FloatArrayStack(); deathDurationStack.Initialize(this, AmpsHelpers.eStackFunction.DeathDuration, typeof(BaseGenericModule).ToString()); stacks.Add(deathDurationStack); customScalarStack = new FloatArrayStack(); customScalarStack.Initialize(this, AmpsHelpers.eStackFunction.CustomScalar, typeof(BaseGenericModule).ToString()); stacks.Add(customScalarStack); customVectorStack = new VectorArrayStack(); customVectorStack.Initialize(this, AmpsHelpers.eStackFunction.CustomVector, typeof(BaseGenericModule).ToString()); stacks.Add(customVectorStack); accelerationStack = new VectorArrayStack(); accelerationStack.Initialize(this, AmpsHelpers.eStackFunction.Acceleration, typeof(BaseGenericModule).ToString()); accelerationStack.EnableOldValues(); stacks.Add(accelerationStack); velocityStack = new VectorArrayStack(); velocityStack.Initialize(this, AmpsHelpers.eStackFunction.Velocity, typeof(BaseGenericModule).ToString()); velocityStack.EnableOldValues(); stacks.Add(velocityStack); positionStack = new VectorArrayStack(); positionStack.Initialize(this, AmpsHelpers.eStackFunction.Position, typeof(BaseGenericModule).ToString()); positionStack.EnableOldValues(); stacks.Add(positionStack); rotationRateStack = new VectorArrayStack(); rotationRateStack.Initialize(this, AmpsHelpers.eStackFunction.RotationRate, typeof(BaseGenericModule).ToString()); rotationRateStack.EnableOldValues(); stacks.Add(rotationRateStack); rotationStack = new VectorArrayStack(); rotationStack.Initialize(this, AmpsHelpers.eStackFunction.Rotation, typeof(BaseGenericModule).ToString()); rotationStack.EnableOldValues(); stacks.Add(rotationStack); scaleStack = new VectorArrayStack(); scaleStack.Initialize(this, AmpsHelpers.eStackFunction.Scale, typeof(BaseGenericModule).ToString()); stacks.Add(scaleStack); colorStack = new VectorArrayStack(); colorStack.Initialize(this, AmpsHelpers.eStackFunction.Color, typeof(BaseGenericModule).ToString()); stacks.Add(colorStack); pivotOffsetStack = new VectorArrayStack(); pivotOffsetStack.Initialize(this, AmpsHelpers.eStackFunction.PivotOffset, typeof(BaseGenericModule).ToString()); stacks.Add(pivotOffsetStack); multiFunctionStack = new MultiFunctionStack(); multiFunctionStack.Initialize(this, AmpsHelpers.eStackFunction.MultiFunction, typeof(BaseMultiFunctionModule).ToString()); stacks.Add(multiFunctionStack); }