当前位置: 首页>>代码示例>>C#>>正文


C# PlaygroundParticlesC.GetParticleColor方法代码示例

本文整理汇总了C#中ParticlePlayground.PlaygroundParticlesC.GetParticleColor方法的典型用法代码示例。如果您正苦于以下问题:C# PlaygroundParticlesC.GetParticleColor方法的具体用法?C# PlaygroundParticlesC.GetParticleColor怎么用?C# PlaygroundParticlesC.GetParticleColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParticlePlayground.PlaygroundParticlesC的用法示例。


在下文中一共展示了PlaygroundParticlesC.GetParticleColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThreadedCalculations


//.........这里部分代码省略.........
                // 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;
                            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.particleCache[p].color = 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) {
开发者ID:PawkaHub,项目名称:Lore-Unity,代码行数:67,代码来源:PlaygroundParticlesC.cs

示例2: 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.particleCache[p].color = 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] =
开发者ID:PawkaHub,项目名称:Lore-Unity,代码行数:67,代码来源:PlaygroundParticlesC.cs


注:本文中的ParticlePlayground.PlaygroundParticlesC.GetParticleColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。