Ejemplo n.º 1
0
 private static void ScaleSystem(ParticleSystem particles, float scale, bool scalePosition, ParticleScalerOptions options = null)
 {
     if (options == null)
     {
         options = ParticleScaler.defaultOptions;
     }
     if (scalePosition)
     {
         particles.transform.localPosition *= scale;
     }
     ParticleSystem.MainModule main = particles.main;
     main.startSizeMultiplier       *= scale;
     main.gravityModifierMultiplier *= scale;
     main.startSpeedMultiplier      *= scale;
 }
Ejemplo n.º 2
0
 public static void Scale(ParticleSystem particles, float scale, bool includeChildren = true, ParticleScalerOptions options = null)
 {
     ParticleScaler.ScaleSystem(particles, scale, false, options);
     if (includeChildren)
     {
         ParticleSystem[] componentsInChildren = particles.GetComponentsInChildren <ParticleSystem>();
         int num = componentsInChildren.Length;
         while (num-- > 0)
         {
             if (!(componentsInChildren[num] == particles))
             {
                 ParticleScaler.ScaleSystem(componentsInChildren[num], scale, true, options);
             }
         }
     }
 }
Ejemplo n.º 3
0
    private static void ScaleSystem(ParticleSystem particles, float scale, bool scalePosition, ParticleScalerOptions options = null)
    {
        if (options == null)
        {
            options = defaultOptions;
        }
        if (scalePosition)
        {
            particles.transform.localPosition *= scale;
        }

        particles.startSize       *= scale;
        particles.gravityModifier *= scale;
        particles.startSpeed      *= scale;

        if (options.shape)
        {
            var shape = particles.shape;
            shape.radius *= scale;
            shape.box     = shape.box * scale;
        }

        /* Currently disabled due to a bug in Unity 5.3.4.
         * If any of these fields are using "Curves", the editor will shut down when they are modified.
         * If you're not using any curves, feel free to uncomment the following lines;
         */
        if (options.velocity)
        {
            var vel = particles.velocityOverLifetime;
            vel.x = ScaleMinMaxCurve(vel.x, scale);
            vel.y = ScaleMinMaxCurve(vel.y, scale);
            vel.z = ScaleMinMaxCurve(vel.z, scale);
        }

        if (options.clampVelocity)
        {
            var clampVel = particles.limitVelocityOverLifetime;
            clampVel.limitX = ScaleMinMaxCurve(clampVel.limitX, scale);
            clampVel.limitY = ScaleMinMaxCurve(clampVel.limitY, scale);
            clampVel.limitZ = ScaleMinMaxCurve(clampVel.limitZ, scale);
        }

        if (options.force)
        {
            var force = particles.forceOverLifetime;
            force.x = ScaleMinMaxCurve(force.x, scale);
            force.y = ScaleMinMaxCurve(force.y, scale);
            force.z = ScaleMinMaxCurve(force.z, scale);
        }
    }
Ejemplo n.º 4
0
 static public void Scale(ParticleSystem particles, float scale, bool includeChildren = true, ParticleScalerOptions options = null)
 {
     ScaleSystem(particles, scale, false, options);
     if (includeChildren)
     {
         var children = particles.GetComponentsInChildren <ParticleSystem>();
         for (var i = children.Length; i-- > 0;)
         {
             if (children[i] == particles)
             {
                 continue;
             }
             ScaleSystem(children[i], scale, true, options);
         }
     }
 }
Ejemplo n.º 5
0
    static public void ScaleSystem(GameObject root, float scale, bool includeChildren = true, ParticleScalerOptions options = null)
    {
        var children = root.GetComponentsInChildren <ParticleSystem>();

        for (var i = children.Length; i-- > 0;)
        {
            ScaleSystem(children[i], scale, true, options);
        }
    }
Ejemplo n.º 6
0
    private static void ScaleSystem(ParticleSystem particles, float scale, bool scalePosition, ParticleScalerOptions options = null)
    {
        if (options == null)
        {
            options = defaultOptions;
        }


        var id        = particles.GetInstanceID();
        var initScale = PopulateDict(particles);

        particles.startSize       = initScale.startSize * Mathf.Abs(scale);
        particles.gravityModifier = initScale.gravity * Mathf.Abs(scale);
        particles.startSpeed      = initScale.startSpeed * Mathf.Abs(scale);


        var shape = particles.shape;

        shape.radius = initScale.radius * Mathf.Abs(scale);
        shape.scale  = initScale.box * Mathf.Abs(scale);
        if (!particles.velocityOverLifetime.enabled && !particles.forceOverLifetime.enabled && !particles.limitVelocityOverLifetime.enabled)
        {
            ScaleByTransform(particles, scale);
            particles.transform.localPosition = initScale.localPosition * scale;
        }


        if (options.velocity)
        {
            var vel = particles.velocityOverLifetime;
            var x   = initScale.velocity[0];
            var y   = initScale.velocity[1];
            var z   = initScale.velocity[2];

            vel.x = ScaleMinMaxCurve2(x, scale);
            vel.y = ScaleMinMaxCurve2(y, scale);
            vel.z = ScaleMinMaxCurve2(z, scale);
        }

        if (options.clampVelocity)
        {
            var clampVel = particles.limitVelocityOverLifetime;
            var x        = initScale.limitVelocity[0];
            var y        = initScale.limitVelocity[1];
            var z        = initScale.limitVelocity[2];
            clampVel.limitX = ScaleMinMaxCurve2(x, scale);
            clampVel.limitY = ScaleMinMaxCurve2(y, scale);
            clampVel.limitZ = ScaleMinMaxCurve2(z, scale);
        }

        if (options.force)
        {
            var force = particles.forceOverLifetime;
            var x     = initScale.force[0];
            var y     = initScale.force[1];
            var z     = initScale.force[2];
            force.x = ScaleMinMaxCurve2(x, scale);
            force.y = ScaleMinMaxCurve2(y, scale);
            force.z = ScaleMinMaxCurve2(z, scale);
        }
    }