本文整理汇总了C#中ParticlePlayground.PlaygroundParticlesC.InactivateParticle方法的典型用法代码示例。如果您正苦于以下问题:C# PlaygroundParticlesC.InactivateParticle方法的具体用法?C# PlaygroundParticlesC.InactivateParticle怎么用?C# PlaygroundParticlesC.InactivateParticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticlePlayground.PlaygroundParticlesC
的用法示例。
在下文中一共展示了PlaygroundParticlesC.InactivateParticle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThreadedCalculations
public static void ThreadedCalculations(PlaygroundParticlesC playgroundParticles)
{
playgroundParticles.lastTimeUpdated = PlaygroundC.globalTime;
if (playgroundParticles.particleCount==0 ||
playgroundParticles.playgroundCache.color.Length!=playgroundParticles.particleCount ||
playgroundParticles.playgroundCache.targetPosition.Length!=playgroundParticles.particleCount ||
playgroundParticles.playgroundCache.targetDirection.Length!=playgroundParticles.particleCount ||
playgroundParticles.isYieldRefreshing || !PlaygroundC.IsReady()) {
playgroundParticles.isDoneThread = true;
playgroundParticles.threadHadNoActiveParticles = false;
return;
}
if (PlaygroundC.reference.calculate && playgroundParticles.calculate && !playgroundParticles.inTransition && playgroundParticles.hasActiveParticles) {}
else if (playgroundParticles.source!=SOURCEC.Script) {
playgroundParticles.isDoneThread = true;
playgroundParticles.cameFromNonCalculatedFrame = true;
return;
} else {
playgroundParticles.isDoneThread = true;
return;
}
float t = playgroundParticles.t;
// Prepare variables for particle source positions
Matrix4x4 stMx = new Matrix4x4();
Matrix4x4 fMx = new Matrix4x4();
stMx.SetTRS(playgroundParticles.stPos, playgroundParticles.stRot, playgroundParticles.stSca);
fMx.SetTRS(Vector3.zero, playgroundParticles.stRot, new Vector3(1f,1f,1f));
int downResolution = playgroundParticles.skinnedWorldObject.downResolution;
int downResolutionP;
bool noActiveParticles = true;
// Update skinned mesh vertices
if (playgroundParticles.source==SOURCEC.SkinnedWorldObject && playgroundParticles.skinnedWorldObjectReady && PlaygroundC.reference.skinnedMeshThreadMethod==ThreadMethodComponent.InsideParticleCalculation) {
playgroundParticles.skinnedWorldObject.Update();
}
// Misc
int pCount = playgroundParticles.particleCache.Length;
bool applyMask = false;
// Check that cache is correct
if (playgroundParticles.playgroundCache.lifetimeSubtraction.Length!=pCount)
SetLifetimeSubtraction(playgroundParticles);
if (playgroundParticles.playgroundCache.maskAlpha.Length!=pCount) {
playgroundParticles.playgroundCache.maskAlpha = new float[pCount];
playgroundParticles.playgroundCache.isMasked = new bool[pCount];
}
if (playgroundParticles.playgroundCache.manipulatorId.Length!=pCount)
playgroundParticles.playgroundCache.manipulatorId = new int[pCount];
if (playgroundParticles.playgroundCache.excludeFromManipulatorId.Length!=pCount)
playgroundParticles.playgroundCache.excludeFromManipulatorId = new int[pCount];
if (playgroundParticles.playgroundCache.noForce.Length!=pCount)
playgroundParticles.playgroundCache.noForce = new bool[pCount];
if (playgroundParticles.playgroundCache.isNonBirthed.Length!=pCount)
playgroundParticles.playgroundCache.isNonBirthed = new bool[pCount];
if (playgroundParticles.playgroundCache.isFirstLoop.Length!=pCount)
playgroundParticles.playgroundCache.isFirstLoop = new bool[pCount];
if (playgroundParticles.playgroundCache.simulate.Length!=pCount) {
playgroundParticles.playgroundCache.simulate = new bool[pCount];
for (int p = 0; p<pCount; p++)
playgroundParticles.playgroundCache.simulate[p] = true;
}
Color lifetimeColor = new Color();
Vector3 zero = Vector3.zero;
Vector3 up = Vector3.up;
// Calculation loop
for (int p = 0; p<playgroundParticles.particleCount; p++) {
// Check that particle count is correct
if (pCount != playgroundParticles.particleCache.Length || playgroundParticles.isYieldRefreshing) {
playgroundParticles.cameFromNonEmissionFrame = false;
playgroundParticles.isDoneThread = true;
playgroundParticles.threadHadNoActiveParticles = false;
return;
}
// Check simulation
if (!playgroundParticles.playgroundCache.simulate[p]) {
if (playgroundParticles.playgroundCache.rebirth[p] && playgroundParticles.loop) {
playgroundParticles.InactivateParticle(p);
}
continue;
} else {
noActiveParticles = false;
}
// Prepare variables inside scope
bool hasLifetimeColors = (playgroundParticles.lifetimeColors.Count>0);
float manipulatorDistance;
Vector3 deltaVelocity;
Vector3 manipulatorPosition;
float normalizedLife = Mathf.Clamp01 (playgroundParticles.playgroundCache.life[p]/(playgroundParticles.lifetime-playgroundParticles.playgroundCache.lifetimeSubtraction[p]));
float evaluatedLife;
float lifetimePositioningTimeScale = 1f;
if (playgroundParticles.applyLifetimePositioningTimeScale)
//.........这里部分代码省略.........
示例2: ThreadedCalculations
//.........这里部分代码省略.........
playgroundParticles.playgroundCache.noForce = new bool[pCount];
if (playgroundParticles.playgroundCache.isNonBirthed.Length!=pCount)
playgroundParticles.playgroundCache.isNonBirthed = new bool[pCount];
if (playgroundParticles.playgroundCache.isFirstLoop.Length!=pCount)
playgroundParticles.playgroundCache.isFirstLoop = new bool[pCount];
if (playgroundParticles.playgroundCache.isCalculatedThisFrame.Length!=pCount)
playgroundParticles.playgroundCache.isCalculatedThisFrame = new bool[pCount];
if (playgroundParticles.playgroundCache.simulate.Length!=pCount) {
playgroundParticles.playgroundCache.simulate = new bool[pCount];
for (int p = 0; p<pCount; p++)
playgroundParticles.playgroundCache.simulate[p] = true;
}
if (playgroundParticles.applyParticleMask && (playgroundParticles.playgroundCache.maskSorting==null || playgroundParticles.playgroundCache.maskSorting.Length!=pCount || playgroundParticles.particleMaskSorting!=playgroundParticles.previousMaskSorting))
playgroundParticles.RefreshMaskSorting();
Vector3 zero = Vector3.zero;
Vector3 up = Vector3.up;
float initYpos = PlaygroundC.initialTargetPosition.y;
// Calculation loop
for (int p = 0; p<playgroundParticles.particleCount; p++) {
// Check that particle count is correct
if (pCount != playgroundParticles.particleCache.Length || playgroundParticles.isYieldRefreshing || playgroundParticles.isSettingParticleTime || playgroundParticles.isSettingParticleCount) {
playgroundParticles.cameFromNonEmissionFrame = false;
playgroundParticles.isDoneThread = true;
playgroundParticles.threadHadNoActiveParticles = false;
return;
}
// Check simulation
if (!playgroundParticles.playgroundCache.simulate[p]) {
if (playgroundParticles.playgroundCache.rebirth[p] && playgroundParticles.loop) {
playgroundParticles.InactivateParticle(p);
}
continue;
} else {
noActiveParticles = false;
}
// This particle is about to be calculated
playgroundParticles.playgroundCache.isCalculatedThisFrame[p] = false;
// Prepare variables inside scope
Vector3 deltaVelocity;
float lifeInSeconds = (playgroundParticles.playgroundCache.death[p]-playgroundParticles.playgroundCache.birth[p])-playgroundParticles.playgroundCache.lifetimeSubtraction[p];
float normalizedLife = Mathf.Clamp01(playgroundParticles.playgroundCache.life[p]/lifeInSeconds);
float normalizedP = (p*1f)/(playgroundParticles.particleCount*1f);
float lifetimePositioningTimeScale = 1f;
if (playgroundParticles.applyLifetimePositioningTimeScale)
lifetimePositioningTimeScale = playgroundParticles.lifetimePositioningTimeScale.Evaluate(normalizedLife);
// Apply particle mask
if (playgroundParticles.applyParticleMask) {
int maskedP = playgroundParticles.playgroundCache.maskSorting[p];
if (p<playgroundParticles.particleMask) {
if (playgroundParticles.playgroundCache.maskAlpha[maskedP]<=0 || playgroundParticles.particleMaskTime<=0) {
playgroundParticles.playgroundCache.isMasked[maskedP] = true;
playgroundParticles.playgroundCache.maskAlpha[maskedP] = 0;
playgroundParticles.particleCache[maskedP].size = 0;
} else {
playgroundParticles.playgroundCache.maskAlpha[maskedP] -= (1f/playgroundParticles.particleMaskTime)*playgroundParticles.localDeltaTime;
}
} else {
if (playgroundParticles.playgroundCache.maskAlpha[maskedP]>=1f || playgroundParticles.particleMaskTime<=0) {
playgroundParticles.playgroundCache.isMasked[maskedP] = false;
示例3: SetParticleTimeNowWithRestEmission
// Set life and death of particles after emit has changed
public static void SetParticleTimeNowWithRestEmission(PlaygroundParticlesC playgroundParticles)
{
float currentGlobalTime = PlaygroundC.globalTime;
float currentTime = currentGlobalTime+playgroundParticles.lifetimeOffset;
float emissionDelta = currentGlobalTime-playgroundParticles.emissionStopped;
bool applyDelta = false;
bool hasOverflow = playgroundParticles.source!=SOURCEC.Transform&&(playgroundParticles.overflowOffset!=Vector3.zero||playgroundParticles.applySourceScatter&&(playgroundParticles.sourceScatterMin!=Vector3.zero||playgroundParticles.sourceScatterMax!=Vector3.zero));
if (playgroundParticles.loop && emissionDelta<playgroundParticles.lifetime && emissionDelta>0) {
applyDelta = true;
playgroundParticles.cameFromNonEmissionFrame = true;
}
for (int p = 0; p<playgroundParticles.particleCount; p++) {
if (!applyDelta) {
if (playgroundParticles.sorting!=SORTINGC.Burst || playgroundParticles.sorting==SORTINGC.NearestNeighbor && hasOverflow || playgroundParticles.sorting==SORTINGC.NearestNeighborReversed && hasOverflow) {
playgroundParticles.playgroundCache.life[p] = playgroundParticles.lifetime-(playgroundParticles.lifetime-playgroundParticles.playgroundCache.lifetimeOffset[p]+.01f);
playgroundParticles.playgroundCache.birth[p] = currentTime-playgroundParticles.playgroundCache.life[p];
playgroundParticles.playgroundCache.death[p] = currentTime+(playgroundParticles.lifetime-playgroundParticles.playgroundCache.lifetimeOffset[p]);
if (!playgroundParticles.loop) {
playgroundParticles.InactivateParticle(p);
}
} else {
playgroundParticles.playgroundCache.life[p] = playgroundParticles.lifetime;
playgroundParticles.playgroundCache.birth[p] = currentTime-playgroundParticles.lifetime;
playgroundParticles.playgroundCache.death[p] = currentTime;
}
playgroundParticles.playgroundCache.birthDelay[p] = 0f;
playgroundParticles.playgroundCache.isNonBirthed[p] = true;
playgroundParticles.playgroundCache.isFirstLoop[p] = true;
playgroundParticles.playgroundCache.rebirth[p] = true;
playgroundParticles.playgroundCache.simulate[p] = true;
} else {
playgroundParticles.playgroundCache.birthDelay[p] = emissionDelta;
}
playgroundParticles.playgroundCache.emission[p] = playgroundParticles.emit;
}
}