Particle Playground - Script Reference
3.0.1
Framework for controlling particles in the Unity Engine.
|
The Particle Playground Recorder enables playback and scrubbing of recorded particles. The method used is storing built-in particle arrays as keyframes, then interpolate between current keyframe and next upon playback. More...
Public Member Functions | |
bool | HasRecordedFrames () |
Determines if this Playground Recorder has recorded frames. More... | |
bool | IsRecording () |
Determines if this Playground Recorder is recording. More... | |
bool | IsReplaying () |
Determines if this Playground Recorder is currently replaying recorded data. More... | |
bool | IsInPlayback () |
Determines whether this Playground Recorder is in playback mode (_isReplaying can be in a stopped state but _inPlayback can still be true). More... | |
int | FrameCount () |
Returns the amount of recorded frames. More... | |
int | GetFrameAtTime (float normalizedTime) |
Gets the frame at normalized time. This is always a floored value to the closest frame of the normalizedTime. More... | |
float | GetFloatingFrameAtTime (float normalizedTime) |
Gets the floating frame number at normalized time. Example: Passing in normalizedTime of 0.5 and total FrameCount is 3, the floating frame would return 1.5. More... | |
float | GetTimeAtFrame (int frame) |
Gets the normalized time at specified recorded frame. More... | |
float | GetKeyframeIntervalAtFrame (int frame) |
Gets the keyframe interval at specified frame. More... | |
float | RecordingStarted () |
Returns when the recording started using Time.realtimeSinceStartup. More... | |
void | StartRecording () |
Starts a recording until StopRecording() is called. This overload will by default use the previously set keyframe interval during recording. More... | |
void | StartRecording (float keyframeInterval) |
Starts a recording until StopRecording() is called. This overload takes a keyframe interval as parameter. More... | |
void | StartRecording (float recordingLength, float keyframeInterval) |
Starts a recording with specified length or until StopRecording() is called. This overload takes a recording length and keyframe interval as parameter. More... | |
void | RecordOneFrame () |
Records one frame. This can be useful if you want exact control of when keyframes should be created. More... | |
void | InsertOneFrame (int frame, FrameType frameType=FrameType.Middle) |
Inserts a recorded frame into the specified frame index. This can be useful if you want to add frames into the recording that shouldn't be placed last. Use FrameCount() to determine how many frames you currently have. More... | |
void | StopRecording () |
Stops the ongoing recording. More... | |
void | ClearRecording () |
Clears out the current recorded frames. More... | |
void | Play () |
Starts the playback of this Playground Recorder. More... | |
void | Play (float speed) |
Starts the playback of this Playground Recorder with specified playback speed. More... | |
void | Play (float fromNormalizedTime, float speed, bool repeat) |
Starts the playback of this Playground Recorder with specified starting point, playback speed and if looping should occur. More... | |
void | Pause () |
Pauses the playback of this Playground Recorder. More... | |
void | Stop () |
Stops the playback and recording of this Playground Recorder. More... | |
void | StopAndSerialize () |
Stops the playback and recording of this Playground Recorder and serializes data into Recorder Data. If multithreading is enabled then the serialization will be asynchronous. More... | |
void | Serialize () |
Serializes the current recorded frames into the Recorder Data. If multithreading is enabled then the serialization will be asynchronous. More... | |
void | Load () |
Loads frames from the Recorder Data. More... | |
void | LoadAsync () |
Loads frames from the Recorder Data asynchronously. More... | |
void | Scrub (float normalizedTime) |
Scrub to specified time in particle recording. This will linearly interpolate between the closest recorded frames of the passed in time (normalized between 0f - 1f). More... | |
bool | Trim (float leftTime, float rightTime) |
Trims (remove) the specified frames outside of normalized leftTime to rightTime. Returns true if trimming occurred. More... | |
void | TrimInner (float leftTime, float rightTime) |
Trims (removes) the specified frames inside of normalized leftTime to rightTime. More... | |
void | SetParticleSystemAsCurrentPlayback () |
Sets the particle system's live particles at the current position in playback (using the playhead) of this Playground Recorder. If multithreading is enabled this operation will run asynchronously. More... | |
void | SetParticleSystemAsRecording (float normalizedTime) |
Sets the particle system's live particles at normalized time of the recorded frames. If multithreading is enabled this operation will run asynchronously. More... | |
Public Attributes | |
bool | multithreading = true |
Determines if the particle playback and serialization should run asynchronously on another thread. More... | |
float | keyframeInterval = .1f |
The interval between keyframes while recording. More... | |
float | playbackSpeed = 1f |
The speed of the playback. Set this to a negative value to make the playback go backwards. More... | |
float | playHead = 0 |
The current position of the playhead (scrubber). More... | |
bool | loopPlayback = true |
Determines if the playback should loop when reaching the end of the recording. More... | |
bool | fadeIn = true |
Determines if playback particles should fade in at appearance. This will interpolate from birth color with 0 alpha to the upcoming keyframe's color. More... | |
bool | sizeIn = true |
Determines if playback particles should grow from 0 size at appearance. This will interpolate from 0 size to the upcoming keyframe's size. More... | |
bool | skipInterpolationOnEndFrames = true |
Determines if interpolation should be skipped on a recorded end-frame. This will make the playback let particles instantly jump/cut to the next recorded frame. More... | |
bool | localSpaceOnPlayback = true |
Determines if the particle system should switch simulation space to local upon playback. This enabled you to move the recording around freely in the scene based on its transform. More... | |
PlaygroundParticlesC | playgroundSystem |
The playground system to record and playback into. More... | |
PlaygroundRecorderData | recorderData |
The recorded data for serialization (data storage). More... | |
List< RecordedFrame > | recordedFrames |
The list of recorded frames. Each frame has its own list of particle data, where playback will interpolate between these based on the playhead. More... | |
The Particle Playground Recorder enables playback and scrubbing of recorded particles. The method used is storing built-in particle arrays as keyframes, then interpolate between current keyframe and next upon playback.
Usage: Drag the PlaygroundRecorder.cs onto a particle system you wish to record. Use StartRecording(float keyframeInterval) to start record the particle system then StopRecording() to stop. Use RecordOneFrame() to add a recorded frame, use InsertOneFrame(int frame) to insert a recorded frame. To replay a recording use Play(float fromNormalizedTime, float speed, bool repeat) then Stop() to stop. This is essentially the same as using Scrub() with an increasing time step. Use Pause() to pause during replay. Use Scrub() to scrub to a normalized time (where all recorded frames are measured between 0f to 1f).
void ParticlePlayground.PlaygroundRecorder.ClearRecording | ( | ) |
Clears out the current recorded frames.
int ParticlePlayground.PlaygroundRecorder.FrameCount | ( | ) |
Returns the amount of recorded frames.
float ParticlePlayground.PlaygroundRecorder.GetFloatingFrameAtTime | ( | float | normalizedTime | ) |
Gets the floating frame number at normalized time. Example: Passing in normalizedTime of 0.5 and total FrameCount is 3, the floating frame would return 1.5.
normalizedTime | Normalized time. |
int ParticlePlayground.PlaygroundRecorder.GetFrameAtTime | ( | float | normalizedTime | ) |
Gets the frame at normalized time. This is always a floored value to the closest frame of the normalizedTime.
normalizedTime | Normalized time. |
float ParticlePlayground.PlaygroundRecorder.GetKeyframeIntervalAtFrame | ( | int | frame | ) |
Gets the keyframe interval at specified frame.
frame | Frame. |
float ParticlePlayground.PlaygroundRecorder.GetTimeAtFrame | ( | int | frame | ) |
Gets the normalized time at specified recorded frame.
frame | The recorded frame. |
bool ParticlePlayground.PlaygroundRecorder.HasRecordedFrames | ( | ) |
Determines if this Playground Recorder has recorded frames.
true
if this Playground Recorder has recorded frames; otherwise, false
.void ParticlePlayground.PlaygroundRecorder.InsertOneFrame | ( | int | frame, |
FrameType | frameType = FrameType.Middle |
||
) |
Inserts a recorded frame into the specified frame index. This can be useful if you want to add frames into the recording that shouldn't be placed last. Use FrameCount() to determine how many frames you currently have.
frame | The index of where the frame should be inserted. |
frameType | The type of the inserted frame (by default FrameType.Middle). |
bool ParticlePlayground.PlaygroundRecorder.IsInPlayback | ( | ) |
Determines whether this Playground Recorder is in playback mode (_isReplaying can be in a stopped state but _inPlayback can still be true).
true
if this Playground Recorder is in playback; otherwise, false
.bool ParticlePlayground.PlaygroundRecorder.IsRecording | ( | ) |
Determines if this Playground Recorder is recording.
true
if this Playground Recorder is recording; otherwise, false
.bool ParticlePlayground.PlaygroundRecorder.IsReplaying | ( | ) |
Determines if this Playground Recorder is currently replaying recorded data.
true
if this Playground Recorder is replaying; otherwise, false
.void ParticlePlayground.PlaygroundRecorder.Load | ( | ) |
Loads frames from the Recorder Data.
void ParticlePlayground.PlaygroundRecorder.LoadAsync | ( | ) |
Loads frames from the Recorder Data asynchronously.
void ParticlePlayground.PlaygroundRecorder.Pause | ( | ) |
Pauses the playback of this Playground Recorder.
void ParticlePlayground.PlaygroundRecorder.Play | ( | ) |
Starts the playback of this Playground Recorder.
void ParticlePlayground.PlaygroundRecorder.Play | ( | float | speed | ) |
Starts the playback of this Playground Recorder with specified playback speed.
speed | The speed of the playback. |
void ParticlePlayground.PlaygroundRecorder.Play | ( | float | fromNormalizedTime, |
float | speed, | ||
bool | repeat | ||
) |
Starts the playback of this Playground Recorder with specified starting point, playback speed and if looping should occur.
fromNormalizedTime | From normalized time in recording. |
speed | The speed of the playback. |
repeat | If set to true then enable looping. |
float ParticlePlayground.PlaygroundRecorder.RecordingStarted | ( | ) |
Returns when the recording started using Time.realtimeSinceStartup.
void ParticlePlayground.PlaygroundRecorder.RecordOneFrame | ( | ) |
Records one frame. This can be useful if you want exact control of when keyframes should be created.
void ParticlePlayground.PlaygroundRecorder.Scrub | ( | float | normalizedTime | ) |
Scrub to specified time in particle recording. This will linearly interpolate between the closest recorded frames of the passed in time (normalized between 0f - 1f).
normalizedTime | The normalized time (0f to 1f). |
void ParticlePlayground.PlaygroundRecorder.Serialize | ( | ) |
Serializes the current recorded frames into the Recorder Data. If multithreading is enabled then the serialization will be asynchronous.
void ParticlePlayground.PlaygroundRecorder.SetParticleSystemAsCurrentPlayback | ( | ) |
Sets the particle system's live particles at the current position in playback (using the playhead) of this Playground Recorder. If multithreading is enabled this operation will run asynchronously.
void ParticlePlayground.PlaygroundRecorder.SetParticleSystemAsRecording | ( | float | normalizedTime | ) |
Sets the particle system's live particles at normalized time of the recorded frames. If multithreading is enabled this operation will run asynchronously.
void ParticlePlayground.PlaygroundRecorder.StartRecording | ( | ) |
Starts a recording until StopRecording() is called. This overload will by default use the previously set keyframe interval during recording.
void ParticlePlayground.PlaygroundRecorder.StartRecording | ( | float | keyframeInterval | ) |
Starts a recording until StopRecording() is called. This overload takes a keyframe interval as parameter.
keyframeInterval | The Keyframe Interval determines the rate of created keyframes (measured in seconds where 1f is 1 second). |
void ParticlePlayground.PlaygroundRecorder.StartRecording | ( | float | recordingLength, |
float | keyframeInterval | ||
) |
Starts a recording with specified length or until StopRecording() is called. This overload takes a recording length and keyframe interval as parameter.
recordingLength | The amount of seconds the recording should be. |
keyframeInterval | The Keyframe Interval determines the rate of created keyframes (measured in seconds where 1f is 1 second). |
void ParticlePlayground.PlaygroundRecorder.Stop | ( | ) |
Stops the playback and recording of this Playground Recorder.
void ParticlePlayground.PlaygroundRecorder.StopAndSerialize | ( | ) |
Stops the playback and recording of this Playground Recorder and serializes data into Recorder Data. If multithreading is enabled then the serialization will be asynchronous.
void ParticlePlayground.PlaygroundRecorder.StopRecording | ( | ) |
Stops the ongoing recording.
bool ParticlePlayground.PlaygroundRecorder.Trim | ( | float | leftTime, |
float | rightTime | ||
) |
Trims (remove) the specified frames outside of normalized leftTime to rightTime. Returns true if trimming occurred.
leftTime | The normalized left time (0 - 1). |
rightTime | The normalized right time (0 - 1). |
void ParticlePlayground.PlaygroundRecorder.TrimInner | ( | float | leftTime, |
float | rightTime | ||
) |
Trims (removes) the specified frames inside of normalized leftTime to rightTime.
leftTime | The normalized left time (0 - 1). |
rightTime | The normalized right time (0 - 1). |
bool ParticlePlayground.PlaygroundRecorder.fadeIn = true |
Determines if playback particles should fade in at appearance. This will interpolate from birth color with 0 alpha to the upcoming keyframe's color.
float ParticlePlayground.PlaygroundRecorder.keyframeInterval = .1f |
The interval between keyframes while recording.
bool ParticlePlayground.PlaygroundRecorder.localSpaceOnPlayback = true |
Determines if the particle system should switch simulation space to local upon playback. This enabled you to move the recording around freely in the scene based on its transform.
bool ParticlePlayground.PlaygroundRecorder.loopPlayback = true |
Determines if the playback should loop when reaching the end of the recording.
bool ParticlePlayground.PlaygroundRecorder.multithreading = true |
Determines if the particle playback and serialization should run asynchronously on another thread.
float ParticlePlayground.PlaygroundRecorder.playbackSpeed = 1f |
The speed of the playback. Set this to a negative value to make the playback go backwards.
PlaygroundParticlesC ParticlePlayground.PlaygroundRecorder.playgroundSystem |
The playground system to record and playback into.
float ParticlePlayground.PlaygroundRecorder.playHead = 0 |
The current position of the playhead (scrubber).
List<RecordedFrame> ParticlePlayground.PlaygroundRecorder.recordedFrames |
The list of recorded frames. Each frame has its own list of particle data, where playback will interpolate between these based on the playhead.
PlaygroundRecorderData ParticlePlayground.PlaygroundRecorder.recorderData |
The recorded data for serialization (data storage).
bool ParticlePlayground.PlaygroundRecorder.sizeIn = true |
Determines if playback particles should grow from 0 size at appearance. This will interpolate from 0 size to the upcoming keyframe's size.
bool ParticlePlayground.PlaygroundRecorder.skipInterpolationOnEndFrames = true |
Determines if interpolation should be skipped on a recorded end-frame. This will make the playback let particles instantly jump/cut to the next recorded frame.