Plugin for Unity

Requirements

  • Unity 2019 or higher

Installation

  1. Start the Unity Editor and open the project in which you want to use effects created with Pixelpart.

  2. Install the base plugin package net.pixelpart.tgz with the Unity Package Manager. See docs.unity3d.com for more details.

  3. If the project uses the Universal Rendering Pipeline (URP), install the package net.pixelpart.urp.tgz as well.

  4. If the project uses the High-Definition Rendering Pipeline (HDRP), install the package net.pixelpart.hdrp.tgz as well.

Usage

Importing effects

Save the effect you created in Pixelpart as a .ppfx file and place it in the Assets folder of your Unity project. Appropriate .asset files are created automatically. The original .ppfx file is no longer needed and can be deleted. If the effect appears too small or too large in your scene, select the corresponding .asset file and set a different scale value in the inspector.

Playing effects

To play the effect, attach the Pixelpart/Effect component to a game object in your scene and move the imported effect asset (with extension .asset) onto the Effect Asset field in the component’s inspector window. The selected effect is then rendered at the position of the game object when running the game.

Unity: Effect inspector

Scripting

An effect and its particle emitters, particle types, force fields and colliders can be controlled dynamically with scripts.

PixelpartEffect

The PixelpartEffect class is responsible for playing a single effect. It provides means to pause and resume the effect, to modify effect inputs and to access scene objects of the effect.

Fields

PixelpartEffectAsset EffectAsset

The attached effect asset.

bool Playing

Whether the effect is currently playing or is paused.

bool Loop

Whether the effect restarts automatically after time LoopTime.

float LoopTime

Time after which the effect loops (only effective if Loop = true).

float Speed

How fast the effect is being played.

float FrameRate

At which rate the effect is simulated, in frames per second.

bool FlipH

Whether the effect is flipped horizontally.

bool FlipV

Whether the effect is flipped vertically.

Properties

bool Is3D { get; }

Whether the effect is 3D or 2D.

float CurrentTime { get; }

Time since the effect has started playing.

float AssetScale { get; }

Scale of the attached effect asset.

Methods

void RestartEffect()

Restarts the effect and removes all existing particles.

void ResetEffect()

Restarts the effect, but does not remove existing particles.

void SpawnParticles(string particleTypeName, int count)

Spawns count particles of the given particle type.

void SetInputBool(string name, bool value)

Sets the effect input name to the given value. The effect input must be of type bool.

void SetInputInt(string name, int value)

Sets the effect input name to the given value. The effect input must be of type int.

void SetInputFloat(string name, float value)

Sets the effect input name to the given value. The effect input must be of type float.

void SetInputFloat2(string name, Vector2 value)

Sets the effect input name to the given value. The effect input must be of type Vector2.

void SetInputFloat3(string name, Vector3 value)

Sets the effect input name to the given value. The effect input must be of type Vector3.

void SetInputFloat4(string name, Vector4 value)

Sets the effect input name to the given value. The effect input must be of type Vector4.

bool GetInputBool(string name)

Returns the value of the effect input name. The effect input must be of type bool.

int GetInputInt(string name)

Returns the value of the effect input name. The effect input must be of type int.

float GetInputFloat(string name)

Returns the value of the effect input name. The effect input must be of type float.

Vector2 GetInputFloat2(string name)

Returns the value of the effect input name. The effect input must be of type Vector2.

Vector3 GetInputFloat3(string name)

Returns the value of the effect input name. The effect input must be of type Vector3.

Vector4 GetInputFloat4(string name)

Returns the value of the effect input name. The effect input must be of type Vector4.

PixelpartParticleEmitter FindParticleEmitter(string name)

Returns the particle emitter with the given name or null if no particle emitter with this name exists.

PixelpartParticleType FindParticleType(string name)

Returns the particle type with the given name or null if no particle type with this name exists.

PixelpartForceField FindForceField(string name)

Returns the force field with the given name or null if no force field with this name exists.

PixelpartCollider FindCollider(string name)

Returns the collider with the given name or null if no collider with this name exists.

PixelpartParticleEmitter GetParticleEmitter(uint id)

Returns the particle emitter with the given id or null if no particle emitter with this id exists.

PixelpartParticleType GetParticleType(uint id)

Returns the particle type with the given id or null if no particle type with this id exists.

PixelpartForceField GetForceField(uint id)

Returns the force field with the given id or null if no force field with this id exists.

PixelpartCollider GetCollider(uint id)

Returns the collider with the given id or null if no collider with this id exists.

PixelpartParticleEmitter GetParticleEmitterAtIndex(int index)

Returns the particle emitter at the given index, starting with 0, or null if no particle emitter exists at this index.

PixelpartParticleType GetParticleTypeAtIndex(int index)

Returns the particle type at the given index, starting with 0, or null if no particle type exists at this index.

PixelpartForceField GetForceFieldAtIndex(int index)

Returns the force field at the given index, starting with 0, or null if no force field exists at this index.

PixelpartCollider GetColliderAtIndex(int index)

Returns the collider at the given index, starting with 0, or null if no collider exists at this index.

PixelpartParticleEmitter

Properties

uint Id { get; }

Unique ID of the emitter.

uint ParentId { get; }

ID of the parent particle type.

string Name { get; }

Name of the emitter.

float LifetimeStart { get; set; }

When the emitter becomes active, in seconds.

float LifetimeDuration { get; set; }

How long the emitter stays active, in seconds.

bool Repeat { get; set; }

Whether the emitter continues to stay active after LifetimeDuration has passed.

bool Active { get; }

Whether the emitter is active and spawns particles at the current point in time.

float LocalTime { get; }

Time fraction the emitter has been active for, in range 0.0 (0%) to 1.0 (100%).

PixelpartAnimatedPropertyFloat3 Position { get; }

Property for the position of the emitter over time.

ShapeType Shape { get; set; }

Shape of the emitter area (Point, Line, Ellipse, Rectangle, Path, Ellipsoid, Cuboid, Cylinder).

int NumShapePoints { get; }

Number of points in the emitter shape if Path is selected as the emitter shape.

PixelpartAnimatedPropertyFloat3 Size { get; }

Animation property for the size of the emitter area over time.

PixelpartAnimatedPropertyFloat3 Orientation { get; }

Animation property for the orientation of the emitter area over time.

DistributionType Distribution { get; set; }

How particles are distributed in the emitter area (Uniform, Center, Hole, Boundary, GridRandom, GridOrdered).

GridOrderType GridOrder { get; set; }

In which order particles are spawned in the GridOrdered particle distribution mode.

Vector3Int GridSize { get; set; }

Number of grid cells in the emitter shape for particle distribution modes GridRandom and GridOrdered

EmissionModeType EmissionMode { get; set; }

When particles are spawned during the lifetime of the emitter (Continuous, BurstStart, BurstEnd).

DirectionModeType DirectionMode { get; set; }

In which direction particles are generated in relation to the emitter area (Fixed, Outwards, Inwards, Inherit, InheritInverse).

PixelpartAnimatedPropertyFloat3 Direction { get; }

Animation property for the emission direction of the emitter in degrees.

PixelpartAnimatedPropertyFloat Spread { get; }

Animation property for the variance in particle directions of the emitter in degrees.

Methods

void AddShapePoint(Vector3 point)

Adds a new point to the emitter shape. Only applicable for emitter shape Path.

void RemoveShapePoint(int index)

Removes the point at index from the emitter shape. Only applicable for emitter shape Path.

void SetShapePoint(int index, Vector3 point)

Changes the location of the point at index in the emitter shape. Only applicable for emitter shape Path.

Vector3 GetShapePoint(int index)

Returns the location of the point at index in the emitter shape. Only applicable for emitter shape Path.

PixelpartParticleType

Properties

uint Id { get; }

Unique ID of the particle type.

uint ParentId { get; }

ID of the emitter creating particles of this type.

string Name { get; }

Name of the particle type.

PixelpartAnimatedPropertyFloat3 Position { get; }

Motion path of particles.

PixelpartAnimatedPropertyFloat NumParticles { get; }

Animation property for the number of the particles spawned.

PixelpartAnimatedPropertyFloat Lifespan { get; }

Animation property for the lifespan of particles.

PixelpartStaticPropertyFloat LifespanVariance { get; }

Property for how much the lifespans of particles vary.

bool PositionRelative { get; set; }

Whether the position of particles is calculated relative to their emitter.

PixelpartStaticPropertyFloat MotionPathForce { get; }

Property for how much the motion path influences the particle position.

PixelpartAnimatedPropertyFloat InitialVelocity { get; }

Animation property for the initial velocity of particles.

PixelpartAnimatedPropertyFloat InheritedVelocity { get; }

Animation property for how much speed particles inherit from the parent particle or emitter.

PixelpartStaticPropertyFloat VelocityVariance { get; }

Property for how much the velocities of particles vary.

PixelpartAnimatedPropertyFloat Acceleration { get; }

Animation property for the linear acceleration of particles over their lifetime.

PixelpartAnimatedPropertyFloat RadialAcceleration { get; }

Animation property for the radial acceleration of particles over their lifetime.

RotationModeType RotationMode { get; set; }

Whether the Rotation property is interpreted as an angle or an angular velocity (Angle, Velocity).

AlignmentModeType AlignmentMode { get; set; }

To which object or vector particles align (None, Camera, Motion, Emission, Emitter).

PixelpartAnimatedPropertyFloat3 InitialRotation { get; }

Animation property for the starting rotation of particles, in degrees.

PixelpartAnimatedPropertyFloat3 Rotation { get; }

Animation property for the rotation (or angular velocity) of particles over their lifetime, in degrees.

PixelpartAnimatedPropertyFloat3 RotationBySpeed { get; }

Animation property of the particles rotation based on velocity.

PixelpartStaticPropertyFloat3 RotationVariance { get; }

Property for how much the rotations of particles vary, in degrees.

PixelpartStaticPropertyFloat3 AngularVelocityVariance { get; }

Property for how much the angular velocities of particles vary, in degrees per second.

PixelpartStaticPropertyFloat3 Pivot { get; }

Property for the rotation center of particles.

PixelpartAnimatedPropertyFloat PhysicalSize { get; }

Animation property for the physical size of particles over their lifetime.

PixelpartAnimatedPropertyFloat Weight { get; }

Animation property for the weight of particles over their lifetime.

PixelpartAnimatedPropertyFloat Bounce { get; }

Animation property for the bounciness of particles over their lifetime.

PixelpartAnimatedPropertyFloat Friction { get; }

Animation property for the friction of particles over their lifetime.

bool Visible { get; set; }

Whether particles of the particle type are visible.

int Layer { get; set; }

Layer on which the particles are drawn inside the effect.

PixelpartAnimatedPropertyFloat InitialSize { get; }

Animation property for the starting size of particles.

PixelpartAnimatedPropertyFloat3 Size { get; }

Animation property for the size of particles as a fraction of their starting size over their lifetime.

PixelpartStaticPropertyFloat SizeVariance { get; }

Property for how much the sizes of particles vary.

PixelpartAnimatedPropertyFloat3 Stretch { get; }

Animation property for how much particles are stretched based on their speed.

PixelpartAnimatedPropertyFloat4 Color { get; }

Animation property for the color of particles over their lifetime.

PixelpartStaticPropertyFloat4 ColorVariance { get; }

Property for how much the colors of particles vary, denoted as variances in Hue, Saturation and Value according to the HSV color model.

PixelpartAnimatedPropertyFloat InitialOpacity { get; }

Animation property for the starting opacity of particles.

PixelpartAnimatedPropertyFloat Opacity { get; }

Animation property for the opacity of particles over their lifetime.

PixelpartStaticPropertyFloat OpacityVariance { get; }

Property for how much the opacities of particles vary.

PixelpartForceField

Properties

uint Id { get; }

Unique ID of the force field.

string Name { get; }

Name of the force field.

float LifetimeStart { get; set; }

Time when the force field becomes active, in seconds.

float LifetimeDuration { get; set; }

How long the force field stays active, in seconds.

bool Repeat { get; set; }

Whether the force field continues to stay active and repeats it behavior after LifetimeDuration has passed.

bool Active { get; }

Whether the force field is active.

float LocalTime { get; }

Time fraction the force field has been active for, in range 0.0 (0%) to 1.0 (100%).

PixelpartAnimatedPropertyFloat3 Position { get; }

Animation property for the position of the force field.

ForceType Type { get; set; }

Type of the force field (AttractionField, AccelerationField, VectorField, NoiseField, DragField, Area).

PixelpartAnimatedPropertyFloat3 Size

Animation property for the size of the force field.

PixelpartAnimatedPropertyFloat3 Orientation { get; }

Animation property for the orientation of the force field, in degrees.

PixelpartAnimatedPropertyFloat Strength { get; }

Animation property for the strength of the force field.

PixelpartAnimatedPropertyFloat3 AccelerationDirection { get; }

Animation property for the force direction of the force field. Only applicable for type AccelerationField.

PixelpartAnimatedPropertyFloat AccelerationDirectionVariance { get; }

Animation property for the variance in force direction between different cells of the force field. Only applicable for type AccelerationField.

PixelpartAnimatedPropertyFloat AccelerationStrengthVariance { get; }

Animation property for the variance in force strength between different cells of the force field. Only applicable for type AccelerationField.

Vector3Int AccelerationGridSize { get; set; }

The number of cells in each dimension of the force field’s grid. Each cell of the grid varies in direction and strength determined by the direction and strength variance values. Only applicable for type AccelerationField.

VectorFieldFilter VectorFilter { get; set; }

How velocity values are interpolated between the cells of the vector field. Only applicable for type VectorField.

PixelpartAnimatedPropertyFloat VectorTightness { get; }

Animation property for how directly particles follow the vectors in the force field. Only applicable for type VectorField.

PixelpartStaticPropertyInt NoiseOctaves { get; }

Property for how many layers of noise are blended together to produce the final velocity vector. Only applicable for type NoiseField.

PixelpartAnimatedPropertyFloat NoiseFrequency { get; }

Animation property of the base frequency of the noise generation. Only applicable for type NoiseField.

PixelpartAnimatedPropertyFloat NoisePersistence { get; }

Animation property for how much the amplitude changes after each noise octave. Only applicable for type NoiseField.

PixelpartAnimatedPropertyFloat NoiseLacunarity { get; }

Animation property for how much the frequency changes after each noise octave. Only applicable for type NoiseField.

bool NoiseAnimated { get; set; }

Whether the noise field is animated. Only applicable for type NoiseField.

PixelpartStaticPropertyFloat NoiseAnimationTimeScale { get; }

Property for how fast the noise field changes. Only applicable for type NoiseField.

PixelpartStaticPropertyFloat NoiseAnimationTimeBase { get; }

Property of the time offset of the noise animation. Only applicable for type NoiseField.

PixelpartStaticPropertyFloat DragVelocityInfluence { get; }

Property how strongly the drag force is influenced by the particle velocity. Only applicable for type DragField.

PixelpartStaticPropertyFloat DragSizeInfluence { get; }

Property for how strongly the drag force is influenced by the particle size. Only applicable for type DragField.

PixelpartCollider

Properties

uint Id { get; }

Unique ID of the collider.

string Name { get; }

Name of the collider object.

float LifetimeStart { get; set; }

Time when the collider becomes active, in seconds.

float LifetimeDuration { get; set; }

How long the collider stays active, in seconds.

bool Repeat { get; set; }

Whether the collider continues to stay active and repeats its behavior after LifetimeDuration has passed.

bool Active { get; }

Whether the collider is currently active.

float LocalTime { get; }

Time fraction the collider has been active for, in range 0.0 (0%) to 1.0 (100%).

int NumPoints { get; }

Number of collider vertices.

PixelpartStaticPropertyFloat Width { get; }

Property of the width of the collider. Only applicable for 3D effects.

PixelpartStaticPropertyFloat Orientation { get; }

Property of the orientation of the collider. Only applicable for 3D effects.

PixelpartStaticPropertyBool KillOnContact { get; }

Property for whether particles are killed on contact with the collider.

PixelpartAnimatedPropertyFloat Bounce { get; }

Animation property for the bounciness of the collider.

PixelpartAnimatedPropertyFloat Friction { get; }

Animation property for the friction of the collider.

Methods

void AddPoint(Vector3 point)

Adds a vertex to the collider at the given position.

void SetPoint(int index, Vector3 point)

Sets the position of the given vertex.

void RemovePoint(int index)

Removes the given vertex from the collider.

Vector3 GetPoint(int index)

Returns the location of the given vertex.

PixelpartAnimatedProperty*

Scene objects of an effect like particle emitters and force fields have properties that change over time. Such properties are represented by the class family PixelpartStaticProperty*. There are classes for the types int, float, Vector2, Vector3 or Vector4 depending on the type of the property, which offer methods to modify the keyframes of the animation.

Properties

InterpolationType Interpolation { get; set; }

Interpolation applied to the animation curve (Off, Linear, Spline).

bool ContainsPoints { get; }

Whether the animation property contains any keyframes.

int NumPoints { get; }

Number of keyframes.

Methods

T Get(float position)

Returns the (interpolated) value of the animation property at time position in range 0.0 to 1.0.

void AddPoint(float position, T value)

Adds a keyframe at time position with value value.

void RemovePoint(int index)

Removes the keyframe with the given index from the animation.

void SetPoint(int index, T value)

Sets the value of the keyframe with the given index to value.

void SetPointPosition(int index, float position)

Move the time of the keyframe with the given index to position.

T GetPoint(int index)

Returns the value of the keyframe with the given index.

void Set(T value)

Sets the animation to a constant with value value.

void Clear()

Removes all keyframes from the animation.

T GetPoint(int index)

Returns the value of the keyframe with the given index.

T GetPointIndex(float position, float epsilon)

Returns the index the keyframe closest to time position.

void EnableAdaptiveCache()

Enables an adaptive cache, which resizes itself automatically if the number of keyframes increases or decreases a lot.

void EnableFixedCache(int size)

Enables a fixed cache with the given size, which only stores up to size different values.

PixelpartStaticProperty*

Scene objects of an effect like particle emitters and force fields have properties that do not change over time. Such properties are represented by the class family PixelpartStaticProperty*. There are classes for the types bool, int, float, Vector2, Vector3 or Vector4 depending on the type of the property.

Methods

T Get()

Returns the value of the property considering active effect inputs.

void SetValue(T value)

Sets the value of the property.

T GetValue()

Returns the value of the property without considering effect inputs.

Platform Support

Platforms

Architectures

Supported

Windows

x64, x86

Linux

x64, x86

macOS

Universal

Android

iOS

Web

Console