| . | |
| using System; |
| |
| using System.Collections.Generic; |
| |
| using UnityEngine; |
| |
| |
| |
| public class DynamicParticleReduction : MonoBehaviour |
| |
| { |
| |
| private void Awake() |
| |
| { |
| |
| this.SaveOriginalStates(); |
| |
| this.ApplySettings(); |
| |
| } |
| |
| |
| |
| public void SaveOriginalStates() |
| |
| { |
| |
| foreach (ParticleSystem particleSystem in this.affectedParticleSystems) |
| |
| { |
| |
| ParticleSystem component = particleSystem.GetComponent<ParticleSystem>(); |
| |
| if (!this.originalCollisionStates.ContainsKey(component)) |
| |
| { |
| |
| ParticleSystem.CollisionModule collision = component.collision; |
| |
| this.originalCollisionStates[component] = collision.enabled; |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| public void ApplySettings() |
| |
| { |
| |
| if (PlatformPrefs.GetInt("DetailedParticleSystems", 1) == 0) |
| |
| { |
| |
| for (int i = 0; i < this.affectedParticleSystems.Count; i++) |
| |
| { |
| |
| this.affectedParticleSystems[i].collision.enabled = false; |
| |
| } |
| |
| return; |
| |
| } |
| |
| this.RestoreOriginalStates(); |
| |
| } |
| |
| |
| |
| public void RestoreOriginalStates() |
| |
| { |
| |
| foreach (KeyValuePair<ParticleSystem, bool> keyValuePair in this.originalCollisionStates) |
| |
| { |
| |
| ParticleSystem key = keyValuePair.Key; |
| |
| bool value = keyValuePair.Value; |
| |
| key.collision.enabled = value; |
| |
| } |
| |
| } |
| |
| |
| |
| [SerializeField] |
| |
| private List<ParticleSystem> affectedParticleSystems; |
| |
| |
| |
| private Dictionary<ParticleSystem, bool> originalCollisionStates = new Dictionary<ParticleSystem, bool>(); |
| |
| } |
| |
| |