本文整理汇总了C#中ParticlePlayground.PlaygroundParticlesC.RefreshSystemRandom方法的典型用法代码示例。如果您正苦于以下问题:C# PlaygroundParticlesC.RefreshSystemRandom方法的具体用法?C# PlaygroundParticlesC.RefreshSystemRandom怎么用?C# PlaygroundParticlesC.RefreshSystemRandom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticlePlayground.PlaygroundParticlesC
的用法示例。
在下文中一共展示了PlaygroundParticlesC.RefreshSystemRandom方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetParticleCount
public static void SetParticleCount(PlaygroundParticlesC playgroundParticles, int amount)
{
if (playgroundParticles.isSettingParticleCount) return;
if (playgroundParticles.isPrewarming) return;
if (amount<0) amount = 0;
if (playgroundParticles.internalRandom01==null)
playgroundParticles.RefreshSystemRandom();
playgroundParticles.particleCount = amount;
playgroundParticles.previousParticleCount = amount;
// Create Particles
playgroundParticles.particleCache = new ParticleSystem.Particle[amount];
playgroundParticles.shurikenParticleSystem.Emit(amount);
playgroundParticles.shurikenParticleSystem.GetParticles(playgroundParticles.particleCache);
playgroundParticles.inTransition = false;
playgroundParticles.hasActiveParticles = true;
playgroundParticles.threadHadNoActiveParticles = false;
playgroundParticles.isSettingParticleCount = true;
PlaygroundC.RunAsync(()=>{
if (!playgroundParticles.isSettingParticleCount) return;
if (playgroundParticles.playgroundCache==null)
playgroundParticles.playgroundCache = new PlaygroundCache();
// Rebuild Cache
playgroundParticles.playgroundCache.size = new float[amount];
playgroundParticles.playgroundCache.birth = new float[amount];
playgroundParticles.playgroundCache.death = new float[amount];
playgroundParticles.playgroundCache.rebirth = new bool[amount];
playgroundParticles.playgroundCache.birthDelay = new float[amount];
playgroundParticles.playgroundCache.life = new float[amount];
playgroundParticles.playgroundCache.lifetimeSubtraction = new float[amount];
playgroundParticles.playgroundCache.rotation = new float[amount];
playgroundParticles.playgroundCache.lifetimeOffset = new float[amount];
playgroundParticles.playgroundCache.emission = new bool[amount];
playgroundParticles.playgroundCache.changedByProperty = new bool[amount];
playgroundParticles.playgroundCache.changedByPropertyColor = new bool[amount];
playgroundParticles.playgroundCache.changedByPropertyColorLerp = new bool[amount];
playgroundParticles.playgroundCache.changedByPropertyColorKeepAlpha = new bool[amount];
playgroundParticles.playgroundCache.changedByPropertySize = new bool[amount];
playgroundParticles.playgroundCache.changedByPropertyTarget = new bool[amount];
playgroundParticles.playgroundCache.changedByPropertyDeath = new bool[amount];
playgroundParticles.playgroundCache.propertyTarget = new int[amount];
playgroundParticles.playgroundCache.propertyId = new int[amount];
playgroundParticles.playgroundCache.excludeFromManipulatorId = new int[amount];
playgroundParticles.playgroundCache.propertyColorId = new int[amount];
playgroundParticles.playgroundCache.manipulatorId = new int[amount];
playgroundParticles.playgroundCache.color = new Color32[amount];
playgroundParticles.playgroundCache.scriptedColor = new Color32[amount];
playgroundParticles.playgroundCache.initialColor = new Color32[amount];
playgroundParticles.playgroundCache.lifetimeColorId = new int[amount];
playgroundParticles.playgroundCache.noForce = new bool[amount];
playgroundParticles.playgroundCache.position = new Vector3[amount];
playgroundParticles.playgroundCache.targetPosition = new Vector3[amount];
playgroundParticles.playgroundCache.targetDirection = new Vector3[amount];
playgroundParticles.playgroundCache.previousTargetPosition = new Vector3[amount];
playgroundParticles.playgroundCache.previousParticlePosition = new Vector3[amount];
playgroundParticles.playgroundCache.collisionParticlePosition = new Vector3[amount];
playgroundParticles.playgroundCache.localSpaceMovementCompensation = new Vector3[amount];
playgroundParticles.playgroundCache.scatterPosition = new Vector3[amount];
playgroundParticles.playgroundCache.velocity = new Vector3[amount];
playgroundParticles.playgroundCache.isMasked = new bool[amount];
playgroundParticles.playgroundCache.maskAlpha = new float[amount];
playgroundParticles.playgroundCache.isNonBirthed = new bool[amount];
playgroundParticles.playgroundCache.isFirstLoop = new bool[amount];
playgroundParticles.playgroundCache.simulate = new bool[amount];
playgroundParticles.playgroundCache.isCalculatedThisFrame = new bool[amount];
playgroundParticles.playgroundCache.maskSorting = null;
for (int i = 0; i<amount; i++) {
playgroundParticles.particleCache[i].size = 0f;
playgroundParticles.playgroundCache.rebirth[i] = true;
playgroundParticles.playgroundCache.simulate[i] = true;
playgroundParticles.playgroundCache.isNonBirthed[i] = true;
playgroundParticles.playgroundCache.isFirstLoop[i] = true;
// Set color gradient id
if (playgroundParticles.colorSource==COLORSOURCEC.LifetimeColors && playgroundParticles.lifetimeColors.Count>0) {
playgroundParticles.lifetimeColorId++;playgroundParticles.lifetimeColorId=playgroundParticles.lifetimeColorId%playgroundParticles.lifetimeColors.Count;
playgroundParticles.playgroundCache.lifetimeColorId[i] = playgroundParticles.lifetimeColorId;
}
}
// Set sizes
SetSizeRandom(playgroundParticles, playgroundParticles.sizeMin, playgroundParticles.sizeMax);
playgroundParticles.previousSizeMin = playgroundParticles.sizeMin;
playgroundParticles.previousSizeMax = playgroundParticles.sizeMax;
// Set rotations
playgroundParticles.playgroundCache.initialRotation = RandomFloat(amount, playgroundParticles.initialRotationMin, playgroundParticles.initialRotationMax, playgroundParticles.internalRandom01);
playgroundParticles.playgroundCache.rotationSpeed = RandomFloat(amount, playgroundParticles.rotationSpeedMin, playgroundParticles.rotationSpeedMax, playgroundParticles.internalRandom01);
playgroundParticles.previousInitialRotationMin = playgroundParticles.initialRotationMin;
playgroundParticles.previousInitialRotationMax = playgroundParticles.initialRotationMax;
playgroundParticles.previousRotationSpeedMin = playgroundParticles.rotationSpeedMin;
playgroundParticles.previousRotationSpeedMax = playgroundParticles.rotationSpeedMax;
// Set velocities
//.........这里部分代码省略.........
示例2: SetLifetime
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);
}
示例3: SetLifetime
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);
}
}
示例4: SetParticleCount
public static void SetParticleCount (PlaygroundParticlesC playgroundParticles, int amount) {
if (playgroundParticles.isSettingParticleCount) return;
if (playgroundParticles.isPrewarming) return;
if (amount<0) amount = 0;
if (playgroundParticles.internalRandom01==null)
playgroundParticles.RefreshSystemRandom();
playgroundParticles.particleCount = amount;
playgroundParticles.previousParticleCount = amount;
// Create Particles
playgroundParticles.particleCache = new ParticleSystem.Particle[amount];
playgroundParticles.shurikenParticleSystem.Emit(amount);
playgroundParticles.shurikenParticleSystem.GetParticles(playgroundParticles.particleCache);
// Clear collision cache
playgroundParticles.collisionCache = null;
playgroundParticles.inTransition = false;
playgroundParticles.hasActiveParticles = true;
playgroundParticles.threadHadNoActiveParticles = false;
playgroundParticles.isSettingParticleCount = true;
if (playgroundParticles.multithreadedStartup)
{
PlaygroundC.RunAsync(()=>{
SetParticleCountAsyncFriendly(playgroundParticles, amount);
}, ThreadPoolMethod.ThreadPool);
}
else SetParticleCountAsyncFriendly(playgroundParticles, amount);
}
示例5: SetLifetime
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;
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) {
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);
}
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*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.Reversed:
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*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) {playgroundParticles.isSettingLifetime = false; 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) {playgroundParticles.isSettingLifetime = false; 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) {playgroundParticles.isSettingLifetime = false; 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) {playgroundParticles.isSettingLifetime = false; 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) {playgroundParticles.isSettingLifetime = false; 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) {playgroundParticles.isSettingLifetime = false; 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) {playgroundParticles.isSettingLifetime = false; return;}
//.........这里部分代码省略.........