Plugin for Unity

Installation

Unity 2017 or higher is required for the plugin. Follow these steps to install the plugin:

  1. Start the Unity Editor and open the project in which you want to use the plugin.
  2. Import the plugin package via the main menu with Assets > Import Package.
  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. Make sure to include the .shader files in the final build. The original .ppfx files are no longer needed and can be deleted. Select the .asset file to set a scale value in the inspector if the effect appears to small or too large in your scene.

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 emitters, force fields, colliders and sprites can be controlled dynamically from script.

PixelpartEffect

Property
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.
bool FlipHWhether the effect is flipped horizontally.
bool FlipVWhether the effect is flipped vertically.
BillboardMode BillboardThe billboard mode, which is used to align the effect to the camera (Disabled, Enabled, EnabledFixedY).
ShadowCastingMode CastShadowsWhether the effect can cast shadows.
bool ReceiveShadowsWhether the effect can receive shadows.
bool UseLightProbesWhether the effect should use light probes.
Transform ProbeAnchorIf used, the effect uses this transform to sample light probes and find the matching reflection probe.
Method
Description
Restart()Restarts the effect and removes all existing particles.
Reset()Restarts the effect, but does not remove existing particles.
GetTime()Returns the time since the effect has started playing.
GetAssetScale()Returns the scale applied to the effect asset.
GetParticleEmitter(string name)Returns the particle emitter with the given name or null if no particle emitter with this name exists.
GetSprite(string name)Returns the sprite with the given name or null if no sprite with this name exists.
GetForceField(string name)Returns the force field with the given name or null if no force field with this name exists.
GetCollider(string name)Returns the collider with the given name or null if no collider with this name exists.
GetParticleEmitterById(uint id)Returns the particle emitter with the given id or null if no particle emitter with this id exists.
GetSpriteById(uint id)Returns the sprite with the given id or null if no sprite with this id exists.
GetForceFieldById(uint id)Returns the force field with the given id or null if no force field with this id exists.
GetColliderById(uint id)Returns the collider with the given id or null if no collider with this id exists.
GetParticleEmitterByIndex(uint index)Returns the particle emitter at the given index, starting with 0, or null if no particle emitter exists at this index.
GetSpriteByIndex(uint index)Returns the sprite at the given index, starting with 0, or null if no sprite exists at this index.
GetForceFieldByIndex(uint index)Returns the force field at the given index, starting with 0, or null if no force field exists at this index.
GetColliderByIndex(uint index)Returns the collider at the given index, starting with 0, or null if no collider exists at this index.

PixelpartParticleEmitter

Property
Description
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.
EmitterShapeType ShapeShape of the emitter area (Point, Line, Ellipse, Rectangle, Path).
EmitterDistributionType DistributionHow particles are distributed in the emitter area (Uniform, Center, CenterReverse, Boundary).
EmitterSpawnModeType SpawnModeIn which direction particles are generated in relation to the emitter area (Fixed, Out, In).
EmitterInstantiationMode InstantiationModeWhen particles are spawned during the lifetime of the emitter (Continuous, Burst, BurstDeath).
uint LayerLayer on which the particles of the emitter are drawn, starting at 0.
bool VisibleWhether the emitter and its particles are visible.
RotationModeType ParticleRotationModeThe rotation mode of particles (Angle, Velocity, Align, AlignPath).
Vector2 ParticlePivotThe point around which particles are rotated, relative to the particle center.
float ParticleLifespanVarianceHow much the lifespans of particles vary.
float ParticleInitialVelocityVarianceHow much the starting velocities of particles vary.
float ParticleRotationVarianceHow much the rotations of particles vary.
float ParticleAngularVelocityVarianceHow much the angular velocities of particles vary.
float ParticleSizeVarianceHow much the sizes of particles vary.
float ParticleOpacityVarianceHow much the opacities of particles vary.
Method
Description
GetName()Returns the name of the emitter.
GetId()Returns the id of the emitter.
GetParentId()Returns the id of the emitter's parent.
IsActive()Returns whether the emitter is active and spawns particles at the current point in time.
GetLocalTime()Returns the time fraction the emitter has been active for, in range 0.0 (0%) to 1.0 (100%).
SpawnParticles(int count)Spawns count particles with the emitter.
GetShapePath()Returns the spawn path of the emitter if Path is selected as the emitter shape.
GetWidth()Returns the curve describing the width of the emitter area.
GetHeight()Returns the curve describing the height of the emitter area.
GetOrientation()Returns the curve describing the orientation of the emitter area in degrees.
GetDirection()Returns the curve describing the direction of the emitter in degrees.
GetSpread()Returns the curve describing the spread of the emitter.
GetNumParticles()Returns the curve describing the number of the particles the emitter spawns per second.
GetParticleLifespan()Returns the curve describing the lifespan of particles of the emitter.
GetMotionPath()Returns the motion path of the emitter.
GetParticleMotionPath()Returns the motion path of particles of the emitter.
GetParticleInitialVelocity()Returns the curve describing the starting velocity of particles of the emitter.
GetParticleAcceleration()Returns the curve describing the acceleration of particles over their lifetime.
GetParticleRadialAcceleration()Returns the curve describing the radial acceleration of particles over their lifetime.
GetParticleDamping()Returns the curve describing the damping of particles over their lifetime.
GetParticleInitialRotation()Returns the curve describing the starting rotation of particles.
GetParticleRotation()Returns the curve describing the rotation of particles over their lifetime.
GetParticleWeight()Returns the curve describing the weight of particles over their lifetime.
GetParticleBounce()Returns the curve describing the bounce of particles over their lifetime.
GetParticleFriction()Returns the curve describing the friction of particles over their lifetime.
GetParticleInitialSize()Returns the curve describing the starting size of particles.
GetParticleSize()Returns the curve describing the size of particles over their lifetime.
GetParticleWidth()Returns the curve describing the width of particles over their lifetime.
GetParticleHeight()Returns the curve describing the height of particles over their lifetime.
GetParticleColor()Returns the gradient describing the colors of particles over their lifetime.
GetParticleInitialOpacity()Returns the curve describing the initial opacity of particles.
GetParticleOpacity()Returns the curve describing the opacity of particles over their lifetime.

PixelpartSprite

Property
Description
float LifetimeStartWhen the sprite becomes active, in seconds.
float LifetimeDurationHow long the sprite stays active, in seconds.
bool RepeatWhether the sprite continues to stay active after LifetimeDuration has passed.
bool AlignWithPathWhether the sprite's orientation aligns with the motion path.
Vector2 PivotThe point around which the sprite rotates, relative to the sprite center.
uint LayerLayer on which the sprite is draw, starting at 0.
bool VisibleWhether the sprite is visible.
Method
Description
GetName()Returns the name of the sprite.
GetId()Returns the id of the sprite.
IsActive()Returns whether the sprite is active.
GetLocalTime()Returns the time fraction the sprite has been active for, in range 0.0 (0%) to 1.0 (100%).
GetWidth()Returns the curve describing the width of the sprite.
GetHeight()Returns the curve describing the height of the sprite.
GetOrientation()Returns the curve describing the orientation of the sprite in degrees.
GetMotionPath()Returns the motion path of the sprite.
GetColor()Returns the color gradient of the sprite.
GetOpacity()Returns the curve describing the opacity of the sprite.

PixelpartForceField

Property
Description
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.
ForceType TypeType of the force field (Point, Area).
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.
Vector2Int GridSizeThe number of columns and rows of the force field's grid. Each cell of the grid varies in direction and strength determined by DirectionVariance and StrengthVariance.
Method
Description
GetName()Returns the name of the force field.
GetId()Returns the id of the force field.
IsActive()Returns whether the force field is active.
GetLocalTime()Returns the time fraction the force field has been active for, in range 0.0 (0%) to 1.0 (100%).
GetWidth()Returns the curve describing the width of the force field.
GetHeight()Returns the curve describing the height of the area force field.
GetOrientation()Returns the curve describing the orientation of the area force field.
GetMotionPath()Returns the motion path of the force field.
GetDirection()Returns the curve describing the force direction of the area force field.
GetStrength()Returns the curve describing the strength of the force field.

PixelpartCollider

Property
Description
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.
Method
Description
GetName()Returns the name of the collider.
GetId()Returns the id of the collider.
IsActive()Returns whether the collider is active.
GetLocalTime()Returns the time fraction the collider has been active for, in range 0.0 (0%) to 1.0 (100%).
AddPoint(Vector2 point)Adds a vertex to the collider at the given position.
SetPoint(int index, Vector2 point)Sets the position of the given vertex.
RemovePoint(int index)Removes the given vertex from the collider.
GetPoint(int index)Returns the position of the given vertex.
GetNumPoints()Returns the number of vertices.
GetBounce()Returns the curve describing the bounce of the collider.
GetFriction()Returns the curve describing the friction of the collider.

PixelpartCurve

Property
Description
InterpolationType InterpolationInterpolation applied to the curve (None, Linear, Spline).
Method
Description
Get(float t)Returns the (interpolated) value of the curve at time t (in range 0.0 to 1.0).
GetPoint(uint index)Returns the value of the curve point with the given index.
Set(float value)Sets the curve to a constant with value value.
AddPoint(float t, float value)Adds a curve point at time t with value value.
SetPoint(uint index, float value)Sets the value of the curve point with the given index to value.
MovePoint(uint index, float delta)Adds delta to the value of the curve point with the given index.
ShiftPoint(uint index, float delta)Moves the curve point with the given index forward or backward in time by delta.
RemovePoint(uint index)Removes the point with the given index from the curve.
Clear()Removes all points from the curve.
GetNumPoints()Returns the number of curve points.
Move(float delta)Adds delta to the value of all curve points.
Shift(float delta)Moves all curve points forward or backward in time by delta.
EnableAdaptiveCache()Enables an adaptive cache, which resizes itself automatically if the number of curve points increases or decreases a lot.
EnableFixedCache(uint size)Enables a fixed cache with the given size, which only stores up to size different values.
GetCacheSize()Returns the size of the cache.

PixelpartPath

Property
Description
InterpolationType InterpolationInterpolation applied to the path (None, Linear, Spline).
Method
Description
Get(float t)Returns the (interpolated) path point at time t (in range 0.0 to 1.0).
GetPoint(uint index)Returns the path point with the given index.
Set(Vector2 value)Sets the path to a constant point with position value.
AddPoint(float t, Vector2 value)Adds a path point at time t with position value.
SetPoint(uint index, Vector2 value)Sets the position of the path point with the given index to value.
MovePoint(uint index, Vector2 delta)Adds delta to the position of the point with the given index.
ShiftPoint(uint index, float delta)Moves the point with the given index forward or backward in time by delta.
RemovePoint(uint index)Removes the point with the given index from the path.
Clear()Removes all points from the path.
GetNumPoints()Returns the number of path points.
Move(Vector2 delta)Adds delta to the position of all path points.
Shift(float delta)Moves all path points forward or backward in time by delta.
EnableAdaptiveCache()Enables an adaptive cache, which resizes itself automatically if the number of path points increases or decreases a lot.
EnableFixedCache(uint size)Enables a fixed cache with the given size, which only stores up to size different values.
GetCacheSize()Returns the size of the cache.

PixelpartGradient

Property
Description
InterpolationType InterpolationInterpolation applied to the gradient (None, Linear, Spline).
Method
Description
Get(float t)Returns the (interpolated) gradient color at time t (in range 0.0 to 1.0).
GetPoint(uint index)Returns the color of the gradient mark with the given index.
Set(Color value)Sets the gradient to the constant color value.
AddPoint(float t, Color value)Adds a gradient mark at time t with color value.
SetPoint(uint index, Color value)Sets the color of the gradient mark with the given index to value.
MovePoint(uint index, Color delta)Adds delta to the color of the gradient mark with the given index.
ShiftPoint(uint index, float delta)Moves the gradient mark with the given index forward or backward in time by delta.
RemovePoint(uint index)Removes the gradient mark with the given index from the gradient.
Clear()Removes all marks from the gradient.
GetNumPoints()Returns the number of gradient marks.
Move(Color delta)Adds delta to the color of all gradient marks.
Shift(float delta)Moves all gradient marks forward or backward in time by delta.
EnableAdaptiveCache()Enables an adaptive cache, which resizes itself automatically if the number of gradient marks increases or decreases a lot.
EnableFixedCache(uint size)Enables a fixed cache with the given size, which only stores up to size different values.
GetCacheSize()Returns the size of the cache.

Platform Support

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