Plugin for Unity
Requirements
- Unity 2017 or higher
Installation
- Start the Unity Editor and open the project in which you want to use the plugin.
- Import the plugin package with Assets > Import Package (main menu).
- 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.
Scripting
An effect and its particle types, emitters, force fields and colliders can be controlled dynamically with scripts.
PixelpartEffect
Field | Description |
---|---|
PixelpartEffectAsset EffectAsset | The attached effect asset. |
bool Playing | Whether the effect is currently playing or not. |
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. |
List<Shader> ParticleShaders | Shaders used to render each particle type. |
bool FlipH | Whether the effect is flipped horizontally. |
bool FlipV | Whether 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 LifetimeStart | When the emitter becomes active, in seconds. |
float LifetimeDuration | How long the emitter stays active, in seconds. |
bool Repeat | Whether 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 Shape | Shape 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 Distribution | How particles are distributed in the emitter area (Uniform , Center , Hole , Boundary ). |
EmissionModeType EmissionMode | When particles are spawned during the lifetime of the emitter (Continuous , BurstStart , BurstEnd ). |
DirectionModeType DirectionMode | In 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 LifespanVariance | How much the lifespans of particles vary. |
bool PositionRelative | Whether the position of particles is calculated relative to their emitter. |
float MotionPathForce | How much the motion path influences the particle position. |
PixelpartCurve InitialVelocity (read-only) | Curve describing the initial velocity of particles. |
float VelocityVariance | How 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 RotationMode | Whether the Rotation property is interpreted as an angle or an angular velocity (Angle , Velocity ). |
AlignmentModeType AlignmentMode | How 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 RotationVariance | How much the rotations of particles vary, in degrees. |
Vector3 AngularVelocityVariance | How much the angular velocities of particles vary, in degrees per second. |
Vector3 Pivot | Point 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 Visible | Whether particles of the particle type are visible. |
int Layer (2D effects) | Layer on which the particles are drawn inside the effect. |
BlendModeType BlendMode | How 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 SizeVariance | How much the sizes of particles vary. |
PixelpartGradient Color (read-only) | Curve describing the color of particles over their lifetime. |
Vector3 ColorVariance | How 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 OpacityVariance | How 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 LifetimeStart | When the force field becomes active, in seconds. |
float LifetimeDuration | How long the force field stays active, in seconds. |
bool Repeat | Whether 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 Type | Type 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 DirectionVariance | How much the force direction is allowed to vary between grid cells of the force field. |
float StrengthVariance | How much the force strength is allowed to vary between grid cells of the force field. |
Vector3Int GridSize | 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 DirectionVariance and StrengthVariance ). |
PixelpartCollider
Property | Description |
---|---|
uint Id (read-only) | Unique ID of the collider. |
string Name (read-only) | Name of the collider. |
float LifetimeStart | When the collider becomes active, in seconds. |
float LifetimeDuration | How long the collider stays active, in seconds. |
bool Repeat | Whether 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 Interpolation | Interpolation 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 Interpolation | Interpolation 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 Interpolation | Interpolation 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
Platforms | Architectures | Supported |
---|---|---|
Windows | x64, x86 | |
Linux | x64, x86 | |
macOS | Universal | |
Android | ||
iOS | ||
Web | ||
Console |