Plugin for Unity

Requirements

  • Unity 2017 or higher

Installation

  1. Start the Unity Editor and open the project in which you want to use the plugin.
  2. Import the plugin package with Assets > Import Package (main menu).
  3. Select all assets and click Import....

Usage

Importing An Effect

Save the effect you created in Pixelpart as a .ppfx file and place it in the Assets folder of your Unity project. Appropriate .asset and .shader 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 An Effect

In order to actually 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.

Unity Play

Scripting

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

PixelpartEffect

Field
Description
PixelpartEffectAsset EffectAssetThe attached effect asset.
bool PlayingWhether the effect is currently playing or not.
bool LoopWhether the effect restarts automatically after time LoopTime.
float LoopTimeTime after which the effect loops (only effective if Loop = true).
float SpeedHow fast the effect is being played.
float FrameRateAt which rate the effect is simulated, in frames per second.
List<Shader> ParticleShadersShaders used to render each particle type.
bool FlipHWhether the effect is flipped horizontally.
bool FlipVWhether the effect is flipped vertically.

Property
Description
bool Is3D (read-only)Whether the effect is 3D or 2D.
float CurrentTime (read-only)Time since the effect has started playing.
float AssetScale (read-only)Scale of the attached effect asset.

Method
Description
void RestartEffect()Restarts the effect and removes all existing particles.
void ResetEffect()Restarts the effect, but does not remove existing particles.
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

Property
Description
uint Id (read-only)Unique ID of the emitter.
uint ParentId (read-only)ID of the parent particle type.
string Name (read-only)Name of the emitter.
float LifetimeStartWhen the emitter becomes active, in seconds.
float LifetimeDurationHow long the emitter stays active, in seconds.
bool RepeatWhether the emitter continues to stay active after LifetimeDuration has passed.
bool Active (read-only)Whether the emitter is active and spawns particles at the current point in time.
float LocalTime (read-only)Time fraction the emitter has been active for, in range 0.0 (0%) to 1.0 (100%).
PixelpartCurve3 Position (read-only)Curve describing the position of the emitter over time.
ShapeType ShapeShape of the emitter area (Point, Line, Ellipse, Rectangle, Path, Ellipsoid, Cuboid, Cylinder).
PixelpartCurve3 Path (read-only)Spawn path of the emitter if Path is selected as the emitter shape.
PixelpartCurve3 Size (read-only)Curve describing the size of the emitter area over time.
PixelpartCurve3 Orientation (read-only)Curve describing the orientation of the emitter area over time.
DistributionType DistributionHow particles are distributed in the emitter area (Uniform, Center, Hole, Boundary).
EmissionModeType EmissionModeWhen particles are spawned during the lifetime of the emitter (Continuous, BurstStart, BurstEnd).
DirectionModeType DirectionModeIn which direction particles are generated in relation to the emitter area (Fixed, Outwards, Inwards).
PixelpartCurve3 Direction (read-only)Curve describing the emission direction of the emitter in degrees.
PixelpartCurve Spread (read-only)Curve describing the variety in particle directions of the emitter in degrees.

PixelpartParticleType

Property
Description
uint Id (read-only)Unique ID of the particle type.
uint ParentId (read-only)ID of the emitter creating particles of this type.
string Name (read-only)Name of the particle type.
PixelpartCurve3 Position (read-only)Motion path of particles.
PixelpartCurve NumParticles (read-only)Curve describing the number of the particles spawned.
PixelpartCurve Lifespan (read-only)Curve describing the lifespan of particles.
float LifespanVarianceHow much the lifespans of particles vary.
bool PositionRelativeWhether the position of particles is calculated relative to their emitter.
float MotionPathForceHow much the motion path influences the particle position.
PixelpartCurve InitialVelocity (read-only)Curve describing the initial velocity of particles.
float VelocityVarianceHow much the velocities of particles vary.
PixelpartCurve Acceleration (read-only)Curve describing the linear acceleration of particles over their lifetime.
PixelpartCurve RadialAcceleration (read-only)Curve describing the radial acceleration of particles over their lifetime.
PixelpartCurve Damping (read-only)Curve describing the damping of particles over their lifetime.
RotationModeType RotationModeWhether the Rotation property is interpreted as an angle or an angular velocity (Angle, Velocity).
AlignmentModeType AlignmentModeHow particles align themselves (None, Camera, Motion, Emission, Emitter).
PixelpartCurve3 InitialRotation (read-only)Curve describing the starting rotation of particles, in degrees.
PixelpartCurve3 Rotation (read-only)Curve describing the rotation (or angular velocity) of particles over their lifetime, in degrees.
Vector3 RotationVarianceHow much the rotations of particles vary, in degrees.
Vector3 AngularVelocityVarianceHow much the angular velocities of particles vary, in degrees per second.
Vector3 PivotPoint around which the particle rotates, relative to the particle center.
PixelpartCurve Weight (read-only)Curve describing the weight of particles over their lifetime.
PixelpartCurve Bounce (read-only)Curve describing the bounciness of particles over their lifetime.
PixelpartCurve Friction (read-only)Curve describing the friction of particles over their lifetime.
bool VisibleWhether particles of the particle type are visible.
int Layer (2D effects)Layer on which the particles are drawn inside the effect.
BlendModeType BlendModeHow particles are blended together with the rest of the effect (Normal, Additive, Subtractive).
PixelpartCurve InitialSize (read-only)Curve describing the starting size of particles.
PixelpartCurve3 Size (read-only)Curve describing the width and height of particles as a fraction of their starting size over their lifetime.
float SizeVarianceHow much the sizes of particles vary.
PixelpartGradient Color (read-only)Curve describing the color of particles over their lifetime.
Vector3 ColorVarianceHow much the colors of particles vary, denoted as variances in Hue, Saturation and Value (HSV model).
PixelpartCurve InitialOpacity (read-only)Returns the curve describing the initial opacity of particles.
PixelpartCurve Opacity (read-only)Returns the curve describing the opacity of particles over their lifetime.
float OpacityVarianceHow much the opacities of particles vary.

Method
Description
void SpawnParticles(int count)Spawns count particles.

PixelpartForceField

Property
Description
uint Id (read-only)Unique ID of the force field.
string Name (read-only)Name of the force field.
float LifetimeStartWhen the force field becomes active, in seconds.
float LifetimeDurationHow long the force field stays active, in seconds.
bool RepeatWhether the force field continues to stay active after LifetimeDuration has passed.
bool Active (read-only)Whether the force field is active.
float LocalTime (read-only)Time fraction the force field has been active for, in range 0.0 (0%) to 1.0 (100%).
PixelpartCurve3 Position (read-only)Motion path of the force field.
ForceType TypeType of the force field (Point, Area).
PixelpartCurve3 Size (read-only)Curve describing the size of the force field.
PixelpartCurve3 Orientation (read-only)Curve describing the orientation of the force field, in degrees.
PixelpartCurve3 Direction (read-only)Curve describing the direction of the area force field, in degrees.
PixelpartCurve Strength (read-only)Curve describing the strength of the force field.
float DirectionVarianceHow much the force direction is allowed to vary between grid cells of the force field.
float StrengthVarianceHow much the force strength is allowed to vary between grid cells of the force field.
Vector3Int GridSizeThe number of cells in each dimension of the force field's grid. Each cell of the grid varies in direction and strength (determined by DirectionVariance and StrengthVariance).

PixelpartCollider

Property
Description
uint Id (read-only)Unique ID of the collider.
string Name (read-only)Name of the collider.
float LifetimeStartWhen the collider becomes active, in seconds.
float LifetimeDurationHow long the collider stays active, in seconds.
bool RepeatWhether the collider continues to stay active after LifetimeDuration has passed.
bool Active (read-only)Whether the collider is active.
float LocalTime (read-only)Time fraction the collider has been active for, in range 0.0 (0%) to 1.0 (100%).
int NumPoints (read-only)Number of collider vertices.
PixelpartCurve Bounce (read-only)Curve describing the bounciness of the collider.
PixelpartCurve Friction (read-only)Curve describing the friction of the collider.

Method
Description
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.

PixelpartCurve

Property
Description
InterpolationType InterpolationInterpolation applied to the curve (None, Linear, Spline).
int NumPoints (read-only)Number of curve points.
int CacheSize (read-only)Size of the cache.

Method
Description
float Get(float t)Returns the (interpolated) value of the curve at time t (in range 0.0 to 1.0).
float GetPoint(int index)Returns the value of the curve point with the given index.
void Set(float value)Sets the curve to a constant with value value.
void AddPoint(float t, float value)Adds a curve point at time t with value value.
void SetPoint(int index, float value)Sets the value of the curve point with the given index to value.
void MovePoint(int index, float delta)Adds delta to the value of the curve point with the given index.
void ShiftPoint(int index, float delta)Moves the curve point with the given index forward or backward in time by delta.
void RemovePoint(int index)Removes the point with the given index from the curve.
void Clear()Removes all points from the curve.
void Move(float delta)Adds delta to the value of all curve points.
void Shift(float delta)Moves all curve points forward or backward in time by delta.
void EnableAdaptiveCache()Enables an adaptive cache, which resizes itself automatically if the number of curve points 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.

PixelpartCurve3

Property
Description
InterpolationType InterpolationInterpolation applied to the path (None, Linear, Spline).
int NumPoints (read-only)Number of curve points.
int CacheSize (read-only)Size of the cache.

Method
Description
Vector3 Get(float t)Returns the (interpolated) path point at time t (in range 0.0 to 1.0).
Vector3 GetPoint(int index)Returns the path point with the given index.
void Set(Vector3 value)Sets the path to a constant point with position value.
void AddPoint(float t, Vector3 value)Adds a path point at time t with position value.
void SetPoint(int index, Vector3 value)Sets the position of the path point with the given index to value.
void MovePoint(int index, Vector3 delta)Adds delta to the position of the point with the given index.
void ShiftPoint(int index, float delta)Moves the point with the given index forward or backward in time by delta.
void RemovePoint(int index)Removes the point with the given index from the path.
void Clear()Removes all points from the path.
void Move(Vector3 delta)Adds delta to the position of all path points.
void Shift(float delta)Moves all path points forward or backward in time by delta.
void EnableAdaptiveCache()Enables an adaptive cache, which resizes itself automatically if the number of path points 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.

PixelpartGradient

Property
Description
InterpolationType InterpolationInterpolation applied to the gradient (None, Linear, Spline).
int NumPoints (read-only)Number of curve points.
int CacheSize (read-only)Size of the cache.

Method
Description
Color Get(float t)Returns the (interpolated) gradient color at time t (in range 0.0 to 1.0).
Color GetPoint(int index)Returns the color of the gradient mark with the given index.
void Set(Color value)Sets the gradient to the constant color value.
void AddPoint(float t, Color value)Adds a gradient mark at time t with color value.
void SetPoint(int index, Color value)Sets the color of the gradient mark with the given index to value.
void MovePoint(int index, Color delta)Adds delta to the color of the gradient mark with the given index.
void ShiftPoint(int index, float delta)Moves the gradient mark with the given index forward or backward in time by delta.
void RemovePoint(int index)Removes the gradient mark with the given index from the gradient.
void Clear()Removes all marks from the gradient.
void Move(Color delta)Adds delta to the color of all gradient marks.
void Shift(float delta)Moves all gradient marks forward or backward in time by delta.
void EnableAdaptiveCache()Enables an adaptive cache, which resizes itself automatically if the number of gradient marks 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.

Platform Support

PlatformsArchitecturesSupported
Windowsx64, x86
Linuxx64, x86
macOSUniversal
Android
iOS
Web
Console