void Update() { if (_particleSystem == null) { return; } #if UNITY_EDITOR if (!Application.isPlaying) { quality = ParticlePalPreview.Quality; this.GetComponent <Renderer>().enabled = isEnabled[(int)quality]; } #endif UpdateVelocity(); bool allConstant = true; foreach (Condition condition in conditions) { Condition.Tuning tuning = condition.tunings[(int)quality]; if (condition.trigger == ParticleManager.TRIGGER.Constant || tuning.type == ParticleManager.TUNING.Constant) { //constant value for all qualities or this particular quality, early out if (condition.parameter == ParticleManager.PARAMETER.StartingColor) { SetParameter(condition.parameter, tuning.constantColor); } else { SetParameter(condition.parameter, tuning.constant); } continue; } allConstant = false; //find the trigger value to use in the tuning phase var triggerVal = 0.0f; switch (condition.trigger) { case (ParticleManager.TRIGGER.Height): triggerVal = this.transform.position.y; break; case (ParticleManager.TRIGGER.Velocity): triggerVal = velocity; break; default: #if UNITY_EDITOR EB.Debug.LogError("ParticlePal trigger {0} is not recognized", condition.trigger.ToString()); #endif break; } //find the interpolated key based of tuning type float interpolateKey = 0.0f; switch (tuning.type) { case (ParticleManager.TUNING.Linear): interpolateKey = Mathf.Clamp01((triggerVal - tuning.minX) / (tuning.maxX - tuning.minX)); break; case (ParticleManager.TUNING.Curve): AnimationCurve curve = tuning.curve; interpolateKey = curve.Evaluate((triggerVal - tuning.minX) / (tuning.maxX - tuning.minX)); break; default: #if UNITY_EDITOR EB.Debug.LogError("ParticlePal tuning {0} is not recognized", condition.tunings[(int)quality].ToString()); #endif break; } //interpolate the float or color switch (condition.parameter) { case (ParticleManager.PARAMETER.StartingColor): Color interpolatedColor = Color.Lerp(tuning.minColor, tuning.maxColor, interpolateKey); SetParameter(condition.parameter, interpolatedColor); break; default: float iterpolatedFloat = interpolateKey * (tuning.maxY - tuning.minY) + tuning.minY; SetParameter(condition.parameter, iterpolatedFloat); break; } } if (allConstant && Application.isPlaying) { //in game, disable the particle pal script, as we have completed an update and set all the constants this.enabled = false; } }
public static void Medium() { Quality = PerformanceInfo.ePARTICLE_QUALITY.Med; }
public static void High() { Quality = PerformanceInfo.ePARTICLE_QUALITY.High; }
public static void Low() { Quality = PerformanceInfo.ePARTICLE_QUALITY.Low; }