本文整理汇总了C#中ParticlePlayground.PlaygroundParticlesC.SetParticleColorInternal方法的典型用法代码示例。如果您正苦于以下问题:C# PlaygroundParticlesC.SetParticleColorInternal方法的具体用法?C# PlaygroundParticlesC.SetParticleColorInternal怎么用?C# PlaygroundParticlesC.SetParticleColorInternal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticlePlayground.PlaygroundParticlesC
的用法示例。
在下文中一共展示了PlaygroundParticlesC.SetParticleColorInternal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rebirth
//.........这里部分代码省略.........
}
if (playgroundParticles.source==SOURCEC.Script) {
// Velocity for script mode
if (!playgroundParticles.onlySourcePositioning && !playgroundParticles.onlyLifetimePositioning)
playgroundParticles.playgroundCache.velocity[p] += playgroundParticles.scriptedEmissionVelocity;
playgroundParticles.playgroundCache.targetPosition[p] = playgroundParticles.scriptedEmissionPosition;
playgroundParticles.particleCache[p].velocity = playgroundParticles.renderModeStretch&&playgroundParticles.applyStretchStartDirection?playgroundParticles.stretchStartDirection:Vector3.zero;
}
// Set new random lifetime
if (playgroundParticles.scriptedLifetime==0) {
if (playgroundParticles.applyRandomLifetimeOnRebirth) {
if (playgroundParticles.lifetimeValueMethod==VALUEMETHOD.Constant) {
playgroundParticles.playgroundCache.lifetimeSubtraction[p] = 0;
} else {
playgroundParticles.playgroundCache.lifetimeSubtraction[p] = playgroundParticles.lifetime-RandomRange (random, playgroundParticles.lifetimeMin, playgroundParticles.lifetime);
}
}
// Set shuriken particles lifetime
if (!playgroundParticles.syncPositionsOnMainThread)
playgroundParticles.particleCache[p].lifetime = playgroundParticles.lifetime;
playgroundParticles.particleCache[p].startLifetime = playgroundParticles.lifetime-playgroundParticles.playgroundCache.lifetimeSubtraction[p];
} else {
playgroundParticles.playgroundCache.lifetimeSubtraction[p] = 0;
if (!playgroundParticles.syncPositionsOnMainThread)
playgroundParticles.particleCache[p].lifetime = playgroundParticles.scriptedLifetime;
playgroundParticles.particleCache[p].startLifetime = playgroundParticles.scriptedLifetime;
}
if (playgroundParticles.playgroundCache.rebirth[p]) {
playgroundParticles.SetParticleColorInternal(p, playgroundParticles.GetParticleColor(p, 0f, (p*1f)/(playgroundParticles.particleCount*1f)));
// Source Scattering
if (playgroundParticles.applySourceScatter && playgroundParticles.source!=SOURCEC.Script) {
if (playgroundParticles.playgroundCache.scatterPosition[p]==Vector3.zero || playgroundParticles.applyRandomScatterOnRebirth) {
if (playgroundParticles.sourceScatterMethod==MINMAXVECTOR3METHOD.Rectangular)
playgroundParticles.playgroundCache.scatterPosition[p] = RandomRange(random, playgroundParticles.sourceScatterMin, playgroundParticles.sourceScatterMax);
else if (playgroundParticles.sourceScatterMethod==MINMAXVECTOR3METHOD.RectangularLinear)
playgroundParticles.playgroundCache.scatterPosition[p] = Vector3.Lerp (playgroundParticles.sourceScatterMin, playgroundParticles.sourceScatterMax, (p*1f)/(playgroundParticles.particleCount*1f));
else if (playgroundParticles.sourceScatterMethod==MINMAXVECTOR3METHOD.SphericalLinear)
playgroundParticles.playgroundCache.scatterPosition[p] = RandomRangeSpherical(random, playgroundParticles.sourceScatterMin.x, playgroundParticles.sourceScatterMax.x, (p*1f)/(playgroundParticles.particleCount*1f));
//else if (playgroundParticles.sourceScatterMethod==MINMAXVECTOR3METHOD.SphericalSector)
// playgroundParticles.playgroundCache.scatterPosition[p] = RandomRangeSpherical(random, playgroundParticles.sourceScatterMin.x, playgroundParticles.sourceScatterMax.x, playgroundParticles.sourceScatterMin.y, playgroundParticles.sourceScatterMax.y);
//else if (playgroundParticles.sourceScatterMethod==MINMAXVECTOR3METHOD.SphericalSectorLinear)
// playgroundParticles.playgroundCache.scatterPosition[p] = RandomRangeSpherical(random, playgroundParticles.sourceScatterMin.x, playgroundParticles.sourceScatterMax.x, playgroundParticles.sourceScatterMin.y, playgroundParticles.sourceScatterMax.y, (p*1f)/(playgroundParticles.particleCount*1f));
else playgroundParticles.playgroundCache.scatterPosition[p] = RandomRangeSpherical(random, playgroundParticles.sourceScatterMin.x, playgroundParticles.sourceScatterMax.x);
}
} else playgroundParticles.playgroundCache.scatterPosition[p] = Vector3.zero;
if (!playgroundParticles.onlyLifetimePositioning) {
playgroundParticles.playgroundCache.position[p] = playgroundParticles.playgroundCache.targetPosition[p];
if (!playgroundParticles.syncPositionsOnMainThread)
playgroundParticles.particleCache[p].position = playgroundParticles.playgroundCache.targetPosition[p];
playgroundParticles.playgroundCache.previousParticlePosition[p] = playgroundParticles.playgroundCache.targetPosition[p];
playgroundParticles.playgroundCache.collisionParticlePosition[p] = playgroundParticles.playgroundCache.targetPosition[p];
} else if (!playgroundParticles.onlySourcePositioning) {
// Lifetime Positioning by Vector3 Animation Curve
if (playgroundParticles.lifetimePositioningUsesSourceDirection && playgroundParticles.source!=SOURCEC.Script) {
playgroundParticles.playgroundCache.position[p] = playgroundParticles.playgroundCache.targetPosition[p]+(playgroundParticles.playgroundCache.targetDirection[p]);
} else {
if (!playgroundParticles.applyLifetimePositioningPositionScale) {
playgroundParticles.playgroundCache.position[p] =
示例2: PropertyManipulator
/// <summary>
/// Calculates the effect from Manipulator's properties.
/// </summary>
/// <param name="playgroundParticles">Playground particles.</param>
/// <param name="thisManipulator">This manipulator.</param>
/// <param name="thisManipulatorProperty">This manipulator property.</param>
/// <param name="p">Particle index.</param>
/// <param name="t">Delta time.</param>
/// <param name="particlePosition">Particle position.</param>
/// <param name="manipulatorPosition">Manipulator position.</param>
/// <param name="localSpace">Is calculation in local space?</param>
/// <param name="contains">Does the Manipulator contain the particle at index?</param>
public static void PropertyManipulator (PlaygroundParticlesC playgroundParticles, ManipulatorObjectC thisManipulator, ManipulatorPropertyC thisManipulatorProperty, float manipulatorStrength, int p, float t, Vector3 particlePosition, Vector3 manipulatorPosition, float manipulatorDistance, bool localSpace, bool contains) {
if (contains) {
switch (thisManipulatorProperty.type) {
// Math Property
case MANIPULATORPROPERTYTYPEC.Math:
if (thisManipulatorProperty.mathProperty.type == MATHMANIPULATORTYPE.Sin || thisManipulatorProperty.mathProperty.type == MATHMANIPULATORTYPE.Cos)
t = playgroundParticles.localTime;
switch (thisManipulatorProperty.mathProperty.property) {
case MATHMANIPULATORPROPERTY.Position:
playgroundParticles.playgroundCache.position[p] = thisManipulatorProperty.mathProperty.EvaluatePosition(playgroundParticles.playgroundCache.position[p], t);
break;
case MATHMANIPULATORPROPERTY.Velocity:
playgroundParticles.playgroundCache.velocity[p] = thisManipulatorProperty.mathProperty.Evaluate(playgroundParticles.playgroundCache.velocity[p], t);
break;
case MATHMANIPULATORPROPERTY.Rotation:
if (!playgroundParticles.rotateTowardsDirection)
playgroundParticles.playgroundCache.rotation[p] = thisManipulatorProperty.mathProperty.Evaluate(playgroundParticles.playgroundCache.rotation[p], t)%360f;
break;
case MATHMANIPULATORPROPERTY.Size:
playgroundParticles.playgroundCache.size[p] = thisManipulatorProperty.mathProperty.Evaluate(playgroundParticles.playgroundCache.size[p], t);
playgroundParticles.playgroundCache.changedByPropertySize[p] = true;
break;
}
break;
// Velocity Property
case MANIPULATORPROPERTYTYPEC.Velocity:
if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None)
playgroundParticles.playgroundCache.velocity[p] = thisManipulatorProperty.useLocalRotation?
thisManipulatorProperty.localVelocity
:
thisManipulatorProperty.velocity;
else {
manipulatorDistance = thisManipulator.strengthDistanceEffect>0?Vector3.SqrMagnitude (manipulatorPosition - particlePosition)/thisManipulator.strengthDistanceEffect:10f;
playgroundParticles.playgroundCache.velocity[p] = Vector3.Lerp(playgroundParticles.playgroundCache.velocity[p], thisManipulatorProperty.useLocalRotation?
thisManipulatorProperty.localVelocity
:
thisManipulatorProperty.velocity, (t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing);
}
break;
// Additive Velocity Property
case MANIPULATORPROPERTYTYPEC.AdditiveVelocity:
manipulatorDistance = thisManipulator.strengthDistanceEffect>0?Vector3.SqrMagnitude (manipulatorPosition - particlePosition)/thisManipulator.strengthDistanceEffect:10f;
playgroundParticles.playgroundCache.velocity[p] += thisManipulatorProperty.useLocalRotation?
thisManipulatorProperty.localVelocity*((t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing)
:
thisManipulatorProperty.velocity*((t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing);
break;
// Color Property
case MANIPULATORPROPERTYTYPEC.Color:
Color staticColor;
if (thisManipulatorProperty.transition == MANIPULATORPROPERTYTRANSITIONC.None) {
if (thisManipulatorProperty.keepColorAlphas) {
staticColor = thisManipulatorProperty.color;
staticColor.a = Mathf.Clamp(playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime).a, 0, staticColor.a);
playgroundParticles.SetParticleColorInternal(p, staticColor);
} else playgroundParticles.SetParticleColorInternal(p, thisManipulatorProperty.color);
} else {
if (thisManipulatorProperty.keepColorAlphas) {
manipulatorDistance = thisManipulator.strengthDistanceEffect>0?Vector3.SqrMagnitude (manipulatorPosition - particlePosition)/thisManipulator.strengthDistanceEffect:10f;
staticColor = thisManipulatorProperty.color;
staticColor.a = Mathf.Clamp(playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime).a, 0, staticColor.a);
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
playgroundParticles.SetParticleColorInternal(p, Color.Lerp(playgroundParticles.particleCache[p].color, staticColor, (t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing));
#else
playgroundParticles.SetParticleColorInternal(p, Color.Lerp(playgroundParticles.particleCache[p].startColor, staticColor, (t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing));
#endif
}
else
{
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
playgroundParticles.SetParticleColorInternal(p, Color.Lerp(playgroundParticles.particleCache[p].color, thisManipulatorProperty.color, (t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing));
#else
playgroundParticles.SetParticleColorInternal(p, Color.Lerp(playgroundParticles.particleCache[p].startColor, thisManipulatorProperty.color, (t*thisManipulatorProperty.strength*manipulatorStrength/manipulatorDistance)/thisManipulator.strengthSmoothing));
#endif
}
playgroundParticles.playgroundCache.changedByPropertyColorLerp[p] = true;
}
// Only color in range of manipulator boundaries
playgroundParticles.playgroundCache.changedByPropertyColor[p] = true;
// Keep alpha of original color
if (thisManipulatorProperty.keepColorAlphas)
//.........这里部分代码省略.........
示例3: ThreadedCalculations
//.........这里部分代码省略.........
// Apply particle mask
if (playgroundParticles.applyParticleMask) {
int maskedP = playgroundParticles.playgroundCache.maskSorting[p];
if (maskedP>=0 && maskedP<playgroundParticles.particleCount) {
if (p<playgroundParticles.particleMask) {
if (playgroundParticles.playgroundCache.maskAlpha[maskedP]<=0 || playgroundParticles.particleMaskTime<=0) {
playgroundParticles.playgroundCache.isMasked[maskedP] = true;
playgroundParticles.playgroundCache.maskAlpha[maskedP] = 0;
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
playgroundParticles.particleCache[maskedP].size = 0;
#else
playgroundParticles.particleCache[maskedP].startSize = 0;
#endif
} 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;
playgroundParticles.playgroundCache.maskAlpha[maskedP] = 1f;
} else {
playgroundParticles.playgroundCache.maskAlpha[maskedP] += (1f/playgroundParticles.particleMaskTime)*playgroundParticles.localDeltaTime;
}
}
}
} else {
playgroundParticles.playgroundCache.isMasked[p] = false;
playgroundParticles.playgroundCache.maskAlpha[p] = 1f;
}
Color32 lifetimeColor = playgroundParticles.GetParticleColor(p, normalizedLife, normalizedP);
// Assign color to particle
playgroundParticles.SetParticleColorInternal(p, lifetimeColor);
// Give Playground Cache its color value
playgroundParticles.playgroundCache.color[p] = lifetimeColor;
// Source positions
if (playgroundParticles.emit) {
if (!playgroundParticles.syncPositionsOnMainThread)
playgroundParticles.playgroundCache.previousTargetPosition[p] = playgroundParticles.playgroundCache.targetPosition[p];
switch (playgroundParticles.source) {
case SOURCEC.State:
if (playgroundParticles.playgroundCache.rebirth[p] || playgroundParticles.onlySourcePositioning || playgroundParticles.onlyLifetimePositioning) {
if (playgroundParticles.applyInitialLocalVelocity && !playgroundParticles.onlyLifetimePositioning)
playgroundParticles.playgroundCache.targetDirection[p] = fMx.MultiplyPoint3x4(Vector3Scale(playgroundParticles.playgroundCache.initialLocalVelocity[p], playgroundParticles.states[playgroundParticles.activeState].GetNormal(p)));
if (playgroundParticles.onlyLifetimePositioning) {
playgroundParticles.playgroundCache.targetDirection[p] = fMx.MultiplyPoint3x4(Vector3Scale(playgroundParticles.lifetimePositioning.Evaluate(normalizedLife*lifetimePositioningTimeScale, playgroundParticles.lifetimePositioningScale), playgroundParticles.states[playgroundParticles.activeState].GetNormal(p)));
if (playgroundParticles.applyLifetimePositioningPositionScale)
playgroundParticles.playgroundCache.targetDirection[p] *= playgroundParticles.lifetimePositioningPositionScale.Evaluate(normalizedLife);
}
playgroundParticles.SetSourcePosition(p);
// Local space compensation calculation
if (playgroundParticles.localSpace && playgroundParticles.applyLocalSpaceMovementCompensation)
playgroundParticles.playgroundCache.localSpaceMovementCompensation[p] = playgroundParticles.playgroundCache.targetPosition[p]-playgroundParticles.playgroundCache.previousTargetPosition[p];
}
break;
case SOURCEC.Transform:
if (playgroundParticles.playgroundCache.rebirth[p] || playgroundParticles.onlySourcePositioning || playgroundParticles.onlyLifetimePositioning) {
if (playgroundParticles.applyInitialLocalVelocity && !playgroundParticles.onlyLifetimePositioning)
if (playgroundParticles.localSpace && playgroundParticles.transformIndex!=playgroundParticles.psTransformNum)
示例4: SetColorWithLifetimeSorting
// Color all particles from lifetime span with sorting
public static void SetColorWithLifetimeSorting (PlaygroundParticlesC playgroundParticles) {
SetLifetime(playgroundParticles, playgroundParticles.sorting, playgroundParticles.lifetime);
Color32 c;
for (int p = 0; p<playgroundParticles.particleCount; p++) {
c = playgroundParticles.lifetimeColor.Evaluate(playgroundParticles.playgroundCache.life[p]/playgroundParticles.lifetime);
playgroundParticles.SetParticleColorInternal(p, c);
}
playgroundParticles.shurikenParticleSystem.SetParticles(playgroundParticles.particleCache, playgroundParticles.particleCache.Length);
}
示例5: SetColorAtLifetime
// Color all particles from evaluated lifetime color value where time is normalized
public static void SetColorAtLifetime (PlaygroundParticlesC playgroundParticles, float time) {
Color32 c = playgroundParticles.lifetimeColor.Evaluate(time/playgroundParticles.lifetime);
for (int p = 0; p<playgroundParticles.particleCount; p++)
playgroundParticles.SetParticleColorInternal(p, c);
playgroundParticles.shurikenParticleSystem.SetParticles(playgroundParticles.particleCache, playgroundParticles.particleCache.Length);
}
示例6: SetAlpha
// Set alphas for particles
public static void SetAlpha (PlaygroundParticlesC playgroundParticles, float alpha) {
Color pColor;
for (int i = 0; i<playgroundParticles.particleCache.Length; i++) {
pColor = playgroundParticles.GetParticleColorInternal(i);
pColor.a = alpha;
playgroundParticles.SetParticleColorInternal(i, pColor);
}
}