IEnumerator LoadRoutine(int loadPointer, int mask) { if (loadTransition && loadTransitionTime>0 && snapshots[loadPointer].transitionMultiplier>0 && transitionAvailable && !isYieldRefreshing) { if (snapshots[loadPointer].loadMaterial && !snapshots[loadPointer].setMaterialAfterTransition && snapshots[loadPointer].settings.particleSystemRenderer.sharedMaterial!=null) particleSystemRenderer.sharedMaterial = snapshots[loadPointer].settings.particleSystemRenderer.sharedMaterial; if (mask>0) { mask = Mathf.Clamp (mask, 0, snapshots[loadPointer].settings.particleCount); if (snapshots[loadPointer].settings.snapshotData.isMasked==null || snapshots[loadPointer].settings.snapshotData.isMasked.Length!=snapshots[loadPointer].settings.particleCount) { snapshots[loadPointer].settings.snapshotData.isMasked = new bool[snapshots[loadPointer].settings.particleCount]; snapshots[loadPointer].settings.snapshotData.maskAlpha = new float[snapshots[loadPointer].settings.particleCount]; } snapshots[loadPointer].settings.applyParticleMask = true; snapshots[loadPointer].settings.particleMask = mask; snapshots[loadPointer].settings.RefreshMaskSorting(); snapshots[loadPointer].settings.snapshotData.maskSorting = (int[])snapshots[loadPointer].settings.playgroundCache.maskSorting.Clone(); for (int i = 0; i<snapshots[loadPointer].settings.particleCount; i++) { int maskedP = snapshots[loadPointer].settings.snapshotData.maskSorting[i]; snapshots[loadPointer].settings.snapshotData.isMasked[maskedP] = i<mask; snapshots[loadPointer].settings.snapshotData.maskAlpha[maskedP] = i<mask?0:1f; } } StartCoroutine(LoadTransition(loadPointer)); while (inTransition) yield return null; } if (isLoading || inTransition || abortTransition) yield break; isLoading = true; int prevParticleCount = particleCount; if (prevParticleCount!=snapshots[loadPointer].settings.particleCount) { SetParticleCount(thisInstance, snapshots[loadPointer].settings.particleCount); while (isSettingParticleCount) yield return null; } snapshots[loadPointer].Load(thisInstance); while (snapshots[loadPointer].IsLoading()) yield return null; lastTimeUpdated = PlaygroundC.globalTime; localTime = PlaygroundC.globalTime; cameFromNonCalculatedFrame = false; cameFromNonEmissionFrame = false; if (snapshots[loadPointer].loadMode!=1) { if (loadFromStart && isYieldRefreshing) yield return null; float tos = snapshots[loadPointer].settings.timeOfSnapshot<=0?snapshots[loadPointer].time:snapshots[loadPointer].settings.timeOfSnapshot; localTime = tos; for (int p = 0; p<particleCount; p++) { playgroundCache.birth[p] = tos+(playgroundCache.birth[p]-tos); playgroundCache.death[p] = tos+(playgroundCache.death[p]-tos); playgroundCache.size[p] = snapshots[loadPointer].settings.snapshotData.size[p]; particleCache[p].size = playgroundCache.size[p]; } lifetime = snapshots[loadPointer].settings.lifetime; previousLifetimeValueMethod = lifetimeValueMethod; previousLifetime = lifetime; previousLifetimeMin = lifetimeMin; previousLifetimeEmission = lifetimeEmission; previousNearestNeighborOrigin = nearestNeighborOrigin; previousNearestNeighborOriginMethod = nearestNeighborOriginMethod; previousNearestNeighborOriginVector3 = nearestNeighborOriginVector3; previousNearestNeighborOriginTransform = nearestNeighborOriginTransform; previousSorting = sorting; localDeltaTime = .001f; t = localDeltaTime; } else if (prevParticleCount!=particleCount) { SetLifetime(thisInstance, sorting, lifetime); yield return null; while (isSettingLifetime) { yield return null; } } hasActiveParticles = true; threadHadNoActiveParticles = false; lastTimeUpdated = PlaygroundC.globalTime; cameFromNonCalculatedFrame = false; cameFromNonEmissionFrame = false; loopExceeded = false; loopExceededOnParticle = -1; isLoading = false; isDoneThread = true; transitionAvailable = true; }
void OnEnable() { if (isSnapshot || isLoading) return; thisInstance = this; thisLayer = particleSystemGameObject.layer; initialized = false; isYieldRefreshing = false; isSettingParticleCount = false; isSettingLifetime = false; hasActiveParticles = true; threadHadNoActiveParticles = false; isDoneThread = true; calculate = true; lastTimeUpdated = PlaygroundC.globalTime; localTime = lastTimeUpdated; emissionStopped = 0; queueEmissionHalt = false; // Set new randoms RefreshSystemRandom(); // Set 0 size to avoid one-frame flash shurikenParticleSystem.startSize = 0f; if (shurikenParticleSystem.isPaused || shurikenParticleSystem.isStopped) shurikenParticleSystem.Play(); // Set initial values previousLifetimeValueMethod = lifetimeValueMethod; previousLifetime = lifetime; previousLifetimeMin = lifetimeMin; previousEmission = emit; previousLoop = loop; previousNearestNeighborOrigin = nearestNeighborOrigin; previousNearestNeighborOriginMethod = nearestNeighborOriginMethod; previousNearestNeighborOriginVector3 = nearestNeighborOriginVector3; previousNearestNeighborOriginTransform = nearestNeighborOriginTransform; previousSorting = sorting; previousParticleCount = particleCount; previousLifetimeEmission = lifetimeEmission; prevSource = source; loopExceeded = false; loopExceededOnParticle = -1; stRot = Quaternion.identity; stDir = new Vector3(); // Initiate all arrays by setting particle count if (particleCache==null) { SetParticleCount(thisInstance, particleCount); } else { // Clean up particle positions SetInitialTargetPosition(thisInstance, PlaygroundC.initialTargetPosition, true); // Refresh StartCoroutine(YieldedRefresh()); } }
public static void SetLifetimeThreadSafe(PlaygroundParticlesC playgroundParticles, SORTINGC sorting, float time) { playgroundParticles.isSettingLifetime = true; PlaygroundC.RunAsync(()=>{ playgroundParticles.lifetime = time; SetLifetimeSubtraction(playgroundParticles); playgroundParticles.playgroundCache.lifetimeOffset = new float[playgroundParticles.particleCount]; int pCount = playgroundParticles.playgroundCache.lifetimeOffset.Length; if (playgroundParticles.source!=SOURCEC.Script) { float lifetimeEmission = playgroundParticles.lifetimeEmission; if (!playgroundParticles.loop) lifetimeEmission*=.95f; switch (sorting) { case SORTINGC.Scrambled: for (int r = 0; r<playgroundParticles.particleCount; r++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} playgroundParticles.playgroundCache.lifetimeOffset[r] = RandomRange(playgroundParticles.internalRandom01, 0f, playgroundParticles.lifetime*lifetimeEmission); } break; case SORTINGC.ScrambledLinear: float slPerc; for (int sl = 0; sl<playgroundParticles.particleCount; sl++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} slPerc = (sl*1f)/(playgroundParticles.particleCount*1f); playgroundParticles.playgroundCache.lifetimeOffset[sl] = playgroundParticles.lifetime*lifetimeEmission*slPerc; } for (int i = playgroundParticles.playgroundCache.lifetimeOffset.Length-1; i>0; i--) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} int r = playgroundParticles.internalRandom01.Next(0,i); float tmp = playgroundParticles.playgroundCache.lifetimeOffset[i]; playgroundParticles.playgroundCache.lifetimeOffset[i] = playgroundParticles.playgroundCache.lifetimeOffset[r]; playgroundParticles.playgroundCache.lifetimeOffset[r] = tmp; } break; case SORTINGC.Burst: // No action needed for spawning all particles at once break; case SORTINGC.Linear: float lPerc; for (int l = 0; l<playgroundParticles.particleCount; l++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} lPerc = (l*1f)/(playgroundParticles.particleCount*1f); playgroundParticles.playgroundCache.lifetimeOffset[l] = playgroundParticles.lifetime*lifetimeEmission*lPerc; } break; case SORTINGC.Reversed: float rPerc; int rInc = 0; for (int r = playgroundParticles.particleCount-1; r>=0; r--) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} rPerc = (rInc*1f)/(playgroundParticles.particleCount*1f); rInc++; playgroundParticles.playgroundCache.lifetimeOffset[r] = playgroundParticles.lifetime*lifetimeEmission*rPerc; } break; case SORTINGC.NearestNeighborReversed: playgroundParticles.nearestNeighborOrigin = Mathf.Clamp(playgroundParticles.nearestNeighborOrigin, 0, playgroundParticles.particleCount-1); float[] nnDist = new float[playgroundParticles.particleCount]; float nnHighest = 0; Vector3 nnrOrigin = Vector3.zero; switch (playgroundParticles.nearestNeighborOriginMethod) { case NEARESTNEIGHBORORIGINMETHOD.SourcePoint: nnrOrigin = playgroundParticles.playgroundCache.targetPosition[playgroundParticles.nearestNeighborOrigin%playgroundParticles.particleCount]; break; case NEARESTNEIGHBORORIGINMETHOD.Vector3: nnrOrigin = playgroundParticles.nearestNeighborOriginVector3; break; case NEARESTNEIGHBORORIGINMETHOD.Transform: nnrOrigin = playgroundParticles.nearestNeighborOriginTransformPosition; break; } for (int nn = 0; nn<playgroundParticles.particleCount; nn++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} nnDist[nn%playgroundParticles.particleCount] = Vector3.SqrMagnitude(nnrOrigin - playgroundParticles.playgroundCache.targetPosition[nn%playgroundParticles.particleCount]); if (nnDist[nn%playgroundParticles.particleCount]>nnHighest) nnHighest = nnDist[nn%playgroundParticles.particleCount]; } if (nnHighest>0) { for (int nn = 0; nn<playgroundParticles.particleCount; nn++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} playgroundParticles.playgroundCache.lifetimeOffset[nn%playgroundParticles.particleCount] = Mathf.Lerp(playgroundParticles.lifetime*(lifetimeEmission-.001f), 0, (nnDist[nn%playgroundParticles.particleCount]/nnHighest)); } } else { for (int nn = 0; nn<playgroundParticles.particleCount; nn++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} playgroundParticles.playgroundCache.lifetimeOffset[nn%playgroundParticles.particleCount] = 0; } } break; case SORTINGC.NearestNeighbor: playgroundParticles.nearestNeighborOrigin = Mathf.Clamp(playgroundParticles.nearestNeighborOrigin, 0, playgroundParticles.particleCount-1); float[] nnrDist = new float[playgroundParticles.particleCount]; float nnrHighest = 0; Vector3 nnOrigin = Vector3.zero; switch (playgroundParticles.nearestNeighborOriginMethod) { case NEARESTNEIGHBORORIGINMETHOD.SourcePoint: nnOrigin = playgroundParticles.playgroundCache.targetPosition[playgroundParticles.nearestNeighborOrigin%playgroundParticles.particleCount]; break; case NEARESTNEIGHBORORIGINMETHOD.Vector3: nnOrigin = playgroundParticles.nearestNeighborOriginVector3; break; case NEARESTNEIGHBORORIGINMETHOD.Transform: nnOrigin = playgroundParticles.nearestNeighborOriginTransformPosition; break; } for (int nnr = 0; nnr<playgroundParticles.particleCount; nnr++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} nnrDist[nnr%playgroundParticles.particleCount] = Vector3.SqrMagnitude(nnOrigin-playgroundParticles.playgroundCache.targetPosition[nnr%playgroundParticles.particleCount]); if (nnrDist[nnr%playgroundParticles.particleCount]>nnrHighest) nnrHighest = nnrDist[nnr%playgroundParticles.particleCount]; } if (nnrHighest>0) { for (int nnr = 0; nnr<playgroundParticles.particleCount; nnr++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} playgroundParticles.playgroundCache.lifetimeOffset[nnr%playgroundParticles.particleCount] = Mathf.Lerp(0, playgroundParticles.lifetime*(lifetimeEmission-.001f), (nnrDist[nnr%playgroundParticles.particleCount]/nnrHighest)); } } else { for (int nnr = 0; nnr<playgroundParticles.particleCount; nnr++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} playgroundParticles.playgroundCache.lifetimeOffset[nnr%playgroundParticles.particleCount] = 0; } } break; case SORTINGC.Custom: for (int cs = playgroundParticles.particleCount-1; cs>=0; cs--) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) {playgroundParticles.isSettingLifetime = false; return;} playgroundParticles.playgroundCache.lifetimeOffset[cs] = playgroundParticles.lifetime*playgroundParticles.lifetimeEmission*playgroundParticles.lifetimeSorting.Evaluate(cs*1f/playgroundParticles.particleCount*1f); } break; } } SetEmissionRate(playgroundParticles); SetParticleTimeNow(playgroundParticles); playgroundParticles.previousLifetime = playgroundParticles.lifetime; playgroundParticles.previousLifetimeEmission = playgroundParticles.lifetimeEmission; playgroundParticles.previousNearestNeighborOrigin = playgroundParticles.nearestNeighborOrigin; playgroundParticles.previousNearestNeighborOriginMethod = playgroundParticles.nearestNeighborOriginMethod; playgroundParticles.previousNearestNeighborOriginVector3 = playgroundParticles.nearestNeighborOriginVector3; playgroundParticles.previousNearestNeighborOriginTransform = playgroundParticles.nearestNeighborOriginTransform; playgroundParticles.previousSorting = playgroundParticles.sorting; playgroundParticles.isDoneThread = true; playgroundParticles.isSettingLifetime = false; playgroundParticles.localDeltaTime = 0f; playgroundParticles.localTime = PlaygroundC.globalTime; playgroundParticles.lastTimeUpdated = PlaygroundC.globalTime; }); }
public static void SetLifetime(PlaygroundParticlesC playgroundParticles, SORTINGC sorting, float time) { if (!playgroundParticles.enabled) return; if (playgroundParticles.isSettingLifetime || playgroundParticles.isSettingParticleCount) return; if (playgroundParticles.internalRandom01==null) playgroundParticles.RefreshSystemRandom(); SetLifetimeThreadSafe (playgroundParticles, sorting, time); }
// Sorts the particles in lifetime public static void SetLifetime (PlaygroundParticlesC playgroundParticles, SORTINGC sorting, float time) { //PlaygroundC.RunAsync(()=>{ playgroundParticles.lifetime = time; playgroundParticles.playgroundCache.lifetimeOffset = new float[playgroundParticles.particleCount]; int pCount = playgroundParticles.playgroundCache.lifetimeOffset.Length; if (playgroundParticles.source!=SOURCEC.Script) { switch (sorting) { case SORTINGC.Scrambled: for (int r = 0; r<playgroundParticles.particleCount; r++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; playgroundParticles.playgroundCache.lifetimeOffset[r] = RandomRange(playgroundParticles.internalRandom02, 0f, playgroundParticles.lifetime); } break; case SORTINGC.ScrambledLinear: float slPerc; for (int sl = 0; sl<playgroundParticles.particleCount; sl++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; slPerc = (sl*1f)/(playgroundParticles.particleCount*1f); playgroundParticles.playgroundCache.lifetimeOffset[sl] = playgroundParticles.lifetime*slPerc; } for (int i = playgroundParticles.playgroundCache.lifetimeOffset.Length-1; i>0; i--) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; int r = playgroundParticles.internalRandom02.Next(0,i); float tmp = playgroundParticles.playgroundCache.lifetimeOffset[i]; playgroundParticles.playgroundCache.lifetimeOffset[i] = playgroundParticles.playgroundCache.lifetimeOffset[r]; playgroundParticles.playgroundCache.lifetimeOffset[r] = tmp; } break; case SORTINGC.Burst: // No action needed for spawning all particles at once break; case SORTINGC.Reversed: float lPerc; for (int l = 0; l<playgroundParticles.particleCount; l++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; lPerc = (l*1f)/(playgroundParticles.particleCount*1f); playgroundParticles.playgroundCache.lifetimeOffset[l] = playgroundParticles.lifetime*lPerc; } break; case SORTINGC.Linear: float rPerc; int rInc = 0; for (int r = playgroundParticles.particleCount-1; r>=0; r--) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; rPerc = (rInc*1f)/(playgroundParticles.particleCount*1f); rInc++; playgroundParticles.playgroundCache.lifetimeOffset[r] = playgroundParticles.lifetime*rPerc; } break; case SORTINGC.NearestNeighbor: playgroundParticles.nearestNeighborOrigin = Mathf.Clamp(playgroundParticles.nearestNeighborOrigin, 0, playgroundParticles.particleCount-1); float[] nnDist = new float[playgroundParticles.particleCount]; float nnHighest = 0; int nn = 0; for (; nn<playgroundParticles.particleCount; nn++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; nnDist[nn%playgroundParticles.particleCount] = Vector3.Distance(playgroundParticles.playgroundCache.targetPosition[playgroundParticles.nearestNeighborOrigin%playgroundParticles.particleCount], playgroundParticles.playgroundCache.targetPosition[nn%playgroundParticles.particleCount]); if (nnDist[nn%playgroundParticles.particleCount]>nnHighest) nnHighest = nnDist[nn%playgroundParticles.particleCount]; } if (nnHighest>0) { for (nn = 0; nn<playgroundParticles.particleCount; nn++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; playgroundParticles.playgroundCache.lifetimeOffset[nn%playgroundParticles.particleCount] = Mathf.Lerp(playgroundParticles.lifetime, 0, (nnDist[nn%playgroundParticles.particleCount]/nnHighest)); } } else { for (nn = 0; nn<playgroundParticles.particleCount; nn++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; playgroundParticles.playgroundCache.lifetimeOffset[nn%playgroundParticles.particleCount] = 0; } } break; case SORTINGC.NearestNeighborReversed: playgroundParticles.nearestNeighborOrigin = Mathf.Clamp(playgroundParticles.nearestNeighborOrigin, 0, playgroundParticles.particleCount-1); float[] nnrDist = new float[playgroundParticles.particleCount]; float nnrHighest = 0; int nnr = 0; for (; nnr<playgroundParticles.particleCount; nnr++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; nnrDist[nnr%playgroundParticles.particleCount] = Vector3.Distance(playgroundParticles.playgroundCache.targetPosition[playgroundParticles.nearestNeighborOrigin], playgroundParticles.playgroundCache.targetPosition[nnr%playgroundParticles.particleCount]); if (nnrDist[nnr%playgroundParticles.particleCount]>nnrHighest) nnrHighest = nnrDist[nnr%playgroundParticles.particleCount]; } if (nnrHighest>0) { for (nnr = 0; nnr<playgroundParticles.particleCount; nnr++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; playgroundParticles.playgroundCache.lifetimeOffset[nnr%playgroundParticles.particleCount] = Mathf.Lerp(0, playgroundParticles.lifetime, (nnrDist[nnr%playgroundParticles.particleCount]/nnrHighest)); } } else { for (nnr = 0; nnr<playgroundParticles.particleCount; nnr++) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; playgroundParticles.playgroundCache.lifetimeOffset[nnr%playgroundParticles.particleCount] = 0; } } break; case SORTINGC.Custom: for (int cs = playgroundParticles.particleCount-1; cs>=0; cs--) { if (pCount!=playgroundParticles.playgroundCache.lifetimeOffset.Length) return; playgroundParticles.playgroundCache.lifetimeOffset[cs] = playgroundParticles.lifetime*playgroundParticles.lifetimeSorting.Evaluate(cs*1f/playgroundParticles.particleCount*1f); } break; } } SetEmissionRate(playgroundParticles); SetParticleTimeNow(playgroundParticles); playgroundParticles.previousLifetime = playgroundParticles.lifetime; //playgroundParticles.isDoneThread = true; //}); }
public static void SetLifetime (PlaygroundParticlesC playgroundParticles, SORTINGC sorting, float time) { if (!playgroundParticles.enabled) return; if (playgroundParticles.isSettingLifetime || playgroundParticles.isSettingParticleCount) return; if (playgroundParticles.internalRandom01==null) playgroundParticles.RefreshSystemRandom(); playgroundParticles.isSettingLifetime = true; if (playgroundParticles.multithreadedStartup) { PlaygroundC.RunAsync(()=>{ SetLifetimeAsyncFriendly (playgroundParticles, sorting, time); }); } else { SetLifetimeAsyncFriendly (playgroundParticles, sorting, time); } }
IEnumerator LoadRoutine(int loadPointer) { if (loadTransition && loadTransitionTime>0 && snapshots[loadPointer].transitionMultiplier>0 && transitionAvailable && !isYieldRefreshing) { if (snapshots[loadPointer].loadMaterial && !snapshots[loadPointer].setMaterialAfterTransition && snapshots[loadPointer].settings.particleSystemRenderer.sharedMaterial!=null) particleSystemRenderer.sharedMaterial = snapshots[loadPointer].settings.particleSystemRenderer.sharedMaterial; StartCoroutine(LoadTransition(loadPointer)); while (inTransition) yield return null; } if (isLoading || inTransition || abortTransition) yield break; isLoading = true; int prevParticleCount = particleCount; if (prevParticleCount!=snapshots[loadPointer].settings.particleCount) { SetParticleCount(thisInstance, snapshots[loadPointer].settings.particleCount); while (isSettingParticleCount) yield return null; } snapshots[loadPointer].Load(thisInstance); while (snapshots[loadPointer].IsLoading()) yield return null; lastTimeUpdated = PlaygroundC.globalTime; cameFromNonCalculatedFrame = false; cameFromNonEmissionFrame = false; //yield return null; if (snapshots[loadPointer].loadMode!=1) { if (loadFromStart && isYieldRefreshing) yield return null; float tos = snapshots[loadPointer].settings.timeOfSnapshot<=0?snapshots[loadPointer].time:snapshots[loadPointer].settings.timeOfSnapshot; for (int p = 0; p<particleCount; p++) { playgroundCache.birth[p] = PlaygroundC.globalTime+(playgroundCache.birth[p]-tos); playgroundCache.death[p] = PlaygroundC.globalTime+(playgroundCache.death[p]-tos); playgroundCache.size[p] = snapshots[loadPointer].settings.snapshotData.size[p]; particleCache[p].size = playgroundCache.size[p]; } lifetime = snapshots[loadPointer].settings.lifetime; previousLifetimeValueMethod = lifetimeValueMethod; previousLifetime = lifetime; previousLifetimeMin = lifetimeMin; previousNearestNeighborOrigin = nearestNeighborOrigin; previousSorting = sorting; localDeltaTime = .001f; } else if (prevParticleCount!=particleCount) { SetLifetime(thisInstance, sorting, lifetime); yield return null; while (isSettingLifetime) { yield return null; } } initNearestNeighborSeq = 6; hasActiveParticles = true; threadHadNoActiveParticles = false; lastTimeUpdated = PlaygroundC.globalTime; cameFromNonCalculatedFrame = false; cameFromNonEmissionFrame = false; loopExceeded = false; loopExceededOnParticle = -1; isLoading = false; isDoneThread = true; transitionAvailable = true; }