Subversion Repository Public Repository

Nextrek

Diff Revisions 112 vs 168 for /3DSpace/Assets/SpaceUnity/Scripts/SU_SpaceParticles.cs

Diff revisions: vs.
  @@ -66,7 +66,7 @@
66 66 void Start () {
67 67 // Cache transform and particle system to improve performance
68 68 _cacheTransform = transform;
69 - _cacheParticleSystem = particleSystem;
69 + _cacheParticleSystem = GetComponent<ParticleSystem>();
70 70 // Calculate the actual spawn and fade distances
71 71 _distanceToSpawn = range * distanceSpawn;
72 72 _distanceToFade = range * distanceFade;
  @@ -89,16 +89,16 @@
89 89 Random.Range(minParticleDriftSpeed, maxParticleDriftSpeed) * driftSpeedMultiplier);
90 90 _newParticle.velocity = _velocity;
91 91 _newParticle.size = Random.Range(minParticleSize, maxParticleSize) * sizeMultiplier;
92 - particleSystem.Emit(1);
92 + GetComponent<ParticleSystem>().Emit(1);
93 93
94 94 }
95 95 }
96 96
97 97 void Update () {
98 - int _numParticles = particleSystem.particleCount;
98 + int _numParticles = GetComponent<ParticleSystem>().particleCount;
99 99 // Get the particles from the particle system
100 100 ParticleSystem.Particle[] _particles = new ParticleSystem.Particle[_numParticles];
101 - particleSystem.GetParticles(_particles);
101 + GetComponent<ParticleSystem>().GetParticles(_particles);
102 102
103 103 // Iterate through the particles and relocation (spawn) and fading
104 104 for (int i = 0; i < _particles.Length; i++) {
  @@ -136,6 +136,6 @@
136 136 }
137 137
138 138 // Set the particles according to above modifications
139 - particleSystem.SetParticles(_particles, _numParticles);
139 + GetComponent<ParticleSystem>().SetParticles(_particles, _numParticles);
140 140 }
141 141 }