Exemple #1
0
    void GenerateParticles()
    {
        if (_particleAccumulation)
        {
            _reservedParticles += particleGenerationSpeed * Time.deltaTime;
        }

        if (_reservedParticles > ShaderConst.WARP_SIZE)
        {
            _reservedParticles -= ShaderConst.WARP_SIZE;

            var posisions = new Vector2[ShaderConst.WARP_SIZE];
            for (var i = 0; i < posisions.Length; i++)
            {
                var posLocal = new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f));
                var tr       = emitters[Random.Range(0, emitters.Length)];
                posisions[i] = tr.TransformPoint(posLocal);
            }
            physics.AddParticle(posisions, 100f);
        }
    }
Exemple #2
0
    void GenerateParticles()
    {
        if (fall)
        {
            _reservedParticles += particleGenerationSpeed * Time.deltaTime;
        }

        var bulk = 0;

        while ((bulk = Mathf.Min((int)_reservedParticles, ShaderConst.WARP_SIZE)) > 1)
        {
            _reservedParticles -= bulk;

            var posisions = new Vector2[bulk];
            for (var i = 0; i < posisions.Length; i++)
            {
                var posLocal = new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f));
                var tr       = emitters[Random.Range(0, emitters.Length)];
                posisions[i] = tr.TransformPoint(posLocal);
            }
            physics.AddParticle(posisions, particleLife);
        }
    }