Particles Module | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Particles Module

    Tiny supports a subset of the particle workflows available in Unity. This subset is referred to as the Particles module. This document provides common use cases, examples, and a reference of Particles components.

    Use Cases and Examples

    This section demonstrates how to use the Particles module through common use cases and usage examples. If a use case or an example is similar to a topic in the Unity User Manual, a link is provided to the appropriate topic.

    Simple Particle System

    1. Create a Sprite2D entity. This will be your proto-particle.
    2. Create an entity.
      1. Add a ParticleEmitter component.
      2. Set the particle property to the Sprite2D entity.
      3. Add a EmitterBoxSource component.

    Modify the ParticleEmitter or the EmitterBoxSource properties to affect the emission (e.g. emission rate).

    Spawn particles with initial modifiers

    After adding a particle system, it is easy to control the state of newly created particles. From the ParticleEmitter component, you can add a related component using the + button.

    1. Add a EmitterInitialScale component to set the scale of each particle on emission.
    2. Add a EmitterInitialRotation component to set the rotation around the z-axis of each particle on emission.
    3. Add a EmitterInitialVelocity component to set the velocity (direction and speed) of each particle on emission.

    For each of these components, it is possible to define the upper and lower bounds for the value; the actual value varies randomly between those bounds.

    Spawn particles with changes over time

    After adding a particle system, it is easy to specify the particle's changes over time. From the ParticleEmitter component, you can add a related component using the + button. Using a change over time component will most likely override any initial value component you provided.

    Using a gradient

    1. Create an empty entity.
      1. Add a Gradient component.
      2. Set the color/alpha values on the gradient so that it represents the lifetime of the particle.
    2. Add a LifetimeColor component to the particle system entity in order to change the particle's color over time.

    Using a curve

    1. Create an empty entity.
      1. Add a Curve component.
      2. Set the response values (y-axis) on the graph so that it represents the lifetime of the particle.

    A Curve entity will be used to specify the value over the particle's lifetime for one of these components:

    1. Add a LifetimeAlpha component to the particle system entity in order to change the particle's transparency over time. Note: This component is ignored when the entity also has a LifetimeColor component with a defined gradient.
    2. Add a LifetimeRotation component to the particle system entity in order to change the particle's rotation over time.
    3. Add a LifetimeScale component to the particle system entity in order to change the particle's scale over time.
    4. Add a LifetimeVelocity component to the particle system entity in order to change the particle's velocity (direction and speed) over time.

    Alternatively, you can check the Modulate property to specify if the particle's value is multiplied with its start value.

    Example: Fireworks

    The Fireworks project found in Assets/UTinySamples covers the use of the Particles Module components.

    This table can be used to associate a Particles Component to a sample entity.

    Particles Components Entity Name
    EmitterBoxSource FireworksEmitter1, FireworksEmitter2, FireworksEmitter3
    EmitterInitialRotation FireworksEmitter3
    EmitterInitialScale FireworksEmitter3
    EmitterInitialVelocity FireworksEmitter1, FireworksEmitter2, FireworksEmitter3
    LifetimeAlpha FireworksEmitter1, AlphaCurve
    LifetimeColor FireworksEmitter2, FireworksEmitter3, ColorGradient1, ColorGradient2
    LifetimeRotation FireworksEmitter3, RotationCurve
    LifetimeScale FireworksEmitter1, FireworksEmitter2, FireworksEmitter3, ScaleCurve
    LifetimeVelocity FireworksEmitter1, FireworksEmitter2, FireworksEmitter3, DirectionCurve, SpeedCurve1, SpeedCurve2
    ParticleEmitter FireworksEmitter1, FireworksEmitter2, FireworksEmitter3

    Components

    Tiny is built around small, lightweight components. This way you only pay for what you need. This design usually creates more component types to represent data held in a single Unity component, which can be confusing at first for some developers.

    Use this table to associate familiar Unity concepts with Tiny.

    Unity Particle System Module Particles Components
    Emission, Shape EmitterBoxSource
    Color Over Lifetime LifetimeAlpha
    Color Over Lifetime LifetimeColor
    Rotation Over Lifetime LifetimeRotation
    Size Over Lifetime LifetimeScale
    Velocity Over Lifetime LifetimeVelocity
    Particle System Main module ParticleEmitter
    Unity Particle System Property Particles Components
    3D Start Rotation, Start Rotation EmitterInitialRotation
    Start Size EmitterInitialScale
    Start Speed EmitterInitialVelocity

    EmitterBoxSource

    • Requires: ParticleEmitter
    • Unity References: Emission module, Shape module

    Change the Shape of emission to a Box with defined position and scale. Particles will be emitted from a random spot inside the box. The rect will be centered around the emitter's position.

    Defaults the emission Rate over Time (number of particles emitted per unit of time) to 10.

    Property Description
    rect The region of the entity to use as the box emitter source. The position is set with the x and y values. The scaling is set with the width and height. Defaults width and height to 50.
    attachToEmitter Sets whether the emitted particle's transform will be a child of this emitter.
    If true, the emission position is set as the entity's local position, and the particle will be added as a transform child.
    If false, the emitter's world position will be added to the emission position, and that result is set as the local position.

    EmitterInitialRotation

    • Requires: ParticleEmitter
    • Unity Reference: Particle System Main module

    Sets the initial angle of each particle on emission.

    Since the particle system is only in 2D coordinates as of right now, the angle is around the z-axis.

    Property Description
    rotation The initial rotation angle in degrees of each particle around the z-axis. If the start and end values are the same, the initial rotation is constant. Otherwise, the rotation is a random value between the start and end values.

    EmitterInitialScale

    • Requires: ParticleEmitter
    • Unity Reference: Particle System Main module

    Sets the initial scale of each particle on emission.

    Property Description
    scale The initial scale of each particle. Defaults to 1. If the start and end values are the same, the initial scale is constant. Otherwise, the scale is a random value between the start and end values.

    EmitterInitialVelocity

    • Requires: ParticleEmitter
    • Unity Reference: Particle System Main module

    Sets the initial velocity (direction and speed) of each particle on emission.

    Property Description
    direction The initial emission direction of each particle from the chosen emission position. The direction is represented by an angle in radians around the z-axis (positive counter clockwise). If the start and end values are the same, the initial direction is constant. Otherwise, the direction is a random value between the start and end values.
    speed The initial speed of each particle in the specified direction. If the start and end values are the same, the initial speed is constant. Otherwise, the speed is a random value between the start and end values.

    LifetimeAlpha

    • Requires: ParticleEmitter
    • Unity Reference: Color Over Lifetime module

    Specifies how a particle's transparency changes over its lifetime. It modifies the Sprite2DRenderer's alpha.

    This component is overrided by the LifetimeColor component. The transparency value is between [0..1].

    Property Description
    curve A curve which defines the particle's transparency, between [0..1], over its lifetime. In this case, the curve is a line graph that shows the transparency over time.
    modulate Sets if the alpha is multiplied with the particle's start alpha.
    If true, the alpha is multiplied.
    If false, the alpha is set directly.

    LifetimeColor

    • Requires: ParticleEmitter
    • Unity Reference: Color Over Lifetime module

    Specifies how a particle's color changes over its lifetime. It modifies the Sprite2DRenderer's color.

    Property Description
    gradient A gradient which defines the particle's color over its lifetime. In this case, the gradient is a visual representation of a colour progression, which simply shows the main colours (which are called stops) and all the intermediate shades between them.
    modulate Sets if the color is multiplied with the particle's start color.
    If true, the color is multiplied.
    If false, the color is set directly.

    LifetimeRotation

    • Requires: ParticleEmitter
    • Unity Reference: Rotation Over Lifetime module

      Specifies how a particle's angle changes over its lifetime. It modifies the Transform's local rotation.

    This component uses angular velocity in the editor and explicit rotation values in the runtime. In Unity, the rotation over lifetime indicates an angular velocity in degrees per second whereas in Tiny, the LifetimeRotation indicates the actual rotation value used at time x.

    Property Description
    curve A curve which defines the particle's rotation in degrees around the z-axis over its lifetime. In this case, the curve is a line graph that sets the rotation over time.
    modulate Sets if the rotation is multiplied with the particle's start rotation.
    If true, the rotation is multiplied.
    If false, the rotation is set directly.

    LifetimeScale

    • Requires: ParticleEmitter
    • Unity Reference: Size Over Lifetime module

    Specifies how a particle's scale changes over its lifetime. It modifies the Transform's scale with a uniform scale (on x, y, z axis).

    Property Description
    curve A curve which defines how the particle's scale changes over its lifetime. In this case, the curve is a line graph that sets the scale over time.
    modulate Sets if the scale is multiplied with the particle's start scale.
    If true, the scale is multiplied.
    If false, the scale is set directly.

    LifetimeVelocity

    • Requires: ParticleEmitter
    • Unity Reference: Velocity Over Lifetime module

    Specifies how a particle's velocity (direction and speed) changes over its lifetime.

    Property Description
    directionCurve A curve which defines how the particle's direction changes over its lifetime. In this case, the curve is a line graph that sets the direction in radians around the z-axis over time.
    speedCurve A curve which defines how the particle's speed changes over its lifetime. In this case, the curve is a line graph that sets the speed over time.
    modulateDirection Sets if the direction is multiplied with the particle's start direction.
    If true, the direction is multiplied.
    If false, the direction is set directly.
    modulateSpeed Sets if the speed is multiplied with the particle's start speed.
    If true, the speed is multiplied.
    If false, the speed is set directly.

    ParticleEmitter

    • Requires: UTiny.Core2D, UTiny.Math
    • Unity References: Graphics.Particle Systems, Particle System Main module

    This is the core particle emitter component. When added to an entity, it becomes an emitter with given characteristics. The system continuously emits particles (loop). It is linked to the source data, the initial values and the lifetime values for particles. It contains global properties that affect the whole system (e.g. lifetime property). Various particle modifiers after initial emit can be added as component (e.g. EmitterInitialScale).

    The Unity Prewarm's property is enabled if the prewarmPercent is equal or more than 0.5.

    Property Description
    particle The UTiny entity attached to the particle system and rendered in run-time. This proto-particle is used as a template.
    maxParticles The maximum number of particles in the system at once. If the limit is reached, some particles are removed. Defaults to 1000.
    emitRate The number of particles emitted per second. Defaults to 10.
    startDelay Delay in seconds before the system starts emitting once enabled.
    prewarmPercent The number of particles to immediately generate at start. It's the multiplier of maxPaticles (0.0: none, 1.0: maxParticles).
    lifetime The lifetime of each particle in seconds. Defaults start (min) and end (max) to 5.

    Systems

    ParticleSystem

    • Updates Before: Shared.InputFence, Shared.RenderingFence

    The main entry system for particles. Spawns particles with given initial characteristics and updates particles' properties (scale, color, alpha, rotation) over time.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023