Example #1
0
        public Color GetColor(ParticleSystem _ps, ParticleSystem.Particle _pc)
        {
            if (_startColor.mode == ParticleSystemGradientMode.Color)
            {
                return(_startColor.color);
            }
            else if (_startColor.mode == ParticleSystemGradientMode.RandomColor)
            {
                return(_startColor.Evaluate(Random.Range(0, 1f)));
            }
            // ParticleSystemGradientMode.Gradient .TwoColors .TwoGradients)
            float fStartTime = ((_ps.time + _pc.remainingLifetime) % _ps.main.duration) / _ps.main.duration;

            return(_startColor.Evaluate(fStartTime));
        }
    /// <param name="gradient"></param>
    /// <param name="samples">Must be 2 or higher</param>
    public SampledMinMaxGradient(ParticleSystem.MinMaxGradient gradient, int samples)
    {
        sampledColor = new NativeArray <Color32>(samples, Allocator.Persistent);
        float timeStep = 1f / (samples - 1);

        for (int i = 0; i < samples; i++)
        {
            sampledColor[i] = gradient.Evaluate(i * timeStep);
        }
    }