My Project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Properties | Events | List of all members
ProGifRecorder Class Reference

Public Types

enum  RecorderState { Paused , PreProcessing , Recording , Stopped }
 

Public Member Functions

 ProGifRecorder (Camera camera=null)
 
void Setup (bool autoAspect, int width, int height, int fps, float recorderTime, int repeat, int quality)
 Initializes the component. Use this if you need to change the recorder settings in a script. This will flush the previously saved frames as settings can't be changed while recording.
 
void Setup (Vector2 gifAspectRatio, int width, int height, int fps, float recorderTime, int repeat, int quality)
 Initializes the component. Use this if you need to change the recorder settings in a script. This will flush the previously saved frames as settings can't be changed while recording. (Use this Setup if you need to crop the image to a specify aspect ratio. The pixels out of the provided aspect ratio will be cut.)
 
RenderTexture GetTexture (int index=-1)
 Gets a stored texture by index in the texture list (You can use it as the preview for displaying on a RawImage/Renderer).
 
void SetGifRotation (ImageRotator.Rotation rotation)
 Set the GIF rotation (Support rotate 0, -90, 90, 180 degrees).
 
void SetGifAspectRatio (Vector2 gifAspectRatio)
 Set the gif aspect ratio.
 
void SetOverrideFrameDelay (float frameDelayInSeconds)
 Set the new frame delay to override the FPS(m_FramePerSecond).
 
void SetTransparent (Color32 color32, byte transparentColorRange)
 Sets the transparent color, hide this color in the GIF. The GIF specification allows setting a color to be transparent. *** Use case: if you want to record gameObject, character or anything else with transparent background, please make sure the background is of solid color(no gradient), and the target object do not contain this color. (Also be reminded, the transparent feature takes more time to encode the GIF)
 
void SetTransparent (bool autoDetectTransparent)
 Auto detects the input image(s) pixels for enable/disable transparent feature. *** Use case: for pre-made images that have transparent pixels manually set. (Also be reminded, the transparent feature takes more time to encode the GIF)
 
void Pause ()
 Pauses recording.
 
void Resume ()
 Resume recording.
 
void Record (Action onDurationEnd)
 Starts or resumes recording. You can't resume while it's pre-processing data to be saved.
 
void Stop ()
 Stops the recording. You can't resume the record after it has been stopped. You can save gif or start a new recording.
 
void FlushMemory ()
 Clears all saved frames from memory and starts fresh.
 
void Save ()
 Saves the stored frames to a gif file. The filename will automatically be generated. Recording will be paused and won't resume automatically. You can use the.
 
void Save (string filename)
 Saves the stored frames to a gif file. If the filename is null or empty, an unique one will be generated. You don't need to add the .gif extension to the name. Recording will be paused and won't resume automatically. You can use the.
 
void ForceSetFrames (Queue< RenderTexture > renderTextures)
 Force assign frames(RenderTexture) to this recorder. This will clear all previous stored frames first.
 
void SetOnRecordAction (Action< float > onRecordAction)
 
void Clear ()
 Clear and Remove the ProGifRecorderComponent from camera.
 

Public Attributes

ProGifRecorderComponent recorderCom = null
 

Properties

RecorderState State [get]
 Current state of the recorder.
 
RenderTexture[] Frames [get]
 
int Width [get]
 
int Height [get]
 
bool IsCustomRatio [get]
 
int FPS [get]
 
ImageRotator.Rotation Rotation [get]
 
string SavedFilePath [get]
 Saved File Path. Empty if recorded gif was not yet saved.
 
float RecordProgress [get]
 
float EstimatedMemoryUse [get]
 

Events

Action OnPreProcessingDone = delegate{}
 Called when the pre-processing step has finished.
 
Action< int, float > OnFileSaveProgress = delegate{}
 Called by each worker thread every time a frame is processed during the save process. The first parameter holds the worker ID and the second one a value in range [0;1] for the actual progress. This callback is probably not thread-safe, use at your own risks.
 
Action< int, string > OnFileSaved = delegate{}
 Called once a gif file has been saved. The first parameter will hold the worker ID and the second one the absolute file path.
 

Member Function Documentation

◆ ForceSetFrames()

void ProGifRecorder.ForceSetFrames ( Queue< RenderTexture >  renderTextures)
inline

Force assign frames(RenderTexture) to this recorder. This will clear all previous stored frames first.

Parameters
renderTexturesRenderTexture list(FIFO).

◆ GetTexture()

RenderTexture ProGifRecorder.GetTexture ( int  index = -1)
inline

Gets a stored texture by index in the texture list (You can use it as the preview for displaying on a RawImage/Renderer).

Returns
RenderTexture.
Parameters
indexRenderTexture index in the list. 0: the first RenderTexture, -1: the last RenderTexture, other value: will clamped between 0 and count-1.

◆ Save() [1/2]

void ProGifRecorder.Save ( )
inline

Saves the stored frames to a gif file. The filename will automatically be generated. Recording will be paused and won't resume automatically. You can use the.

OnPreProcessingDone callback to be notified when the pre-processing step has finished.

◆ Save() [2/2]

void ProGifRecorder.Save ( string  filename)
inline

Saves the stored frames to a gif file. If the filename is null or empty, an unique one will be generated. You don't need to add the .gif extension to the name. Recording will be paused and won't resume automatically. You can use the.

OnPreProcessingDone callback to be notified when the pre-processing step has finished.

Parameters
filenameFile name without extension

◆ SetGifAspectRatio()

void ProGifRecorder.SetGifAspectRatio ( Vector2  gifAspectRatio)
inline

Set the gif aspect ratio.

  • Change during/after PreProcessing state will not be applied.
Parameters
gifAspectRatioAspect ratio for gif.

◆ SetGifRotation()

void ProGifRecorder.SetGifRotation ( ImageRotator::Rotation  rotation)
inline

Set the GIF rotation (Support rotate 0, -90, 90, 180 degrees).

  • Change during/after PreProcessing state will not be applied.
Parameters
rotationRotation: 0, -90, 90, 180 degrees

◆ SetOverrideFrameDelay()

void ProGifRecorder.SetOverrideFrameDelay ( float  frameDelayInSeconds)
inline

Set the new frame delay to override the FPS(m_FramePerSecond).

  • Change during/after PreProcessing state will not be applied.
Parameters
frameDelayInSecondsFrame delay in seconds.

◆ SetTransparent() [1/2]

void ProGifRecorder.SetTransparent ( bool  autoDetectTransparent)
inline

Auto detects the input image(s) pixels for enable/disable transparent feature. *** Use case: for pre-made images that have transparent pixels manually set. (Also be reminded, the transparent feature takes more time to encode the GIF)

Parameters
autoDetectTransparentIf set to true auto detect transparent pixels to enable the transparent feature, else disable the auto detection.

◆ SetTransparent() [2/2]

void ProGifRecorder.SetTransparent ( Color32  color32,
byte  transparentColorRange 
)
inline

Sets the transparent color, hide this color in the GIF. The GIF specification allows setting a color to be transparent. *** Use case: if you want to record gameObject, character or anything else with transparent background, please make sure the background is of solid color(no gradient), and the target object do not contain this color. (Also be reminded, the transparent feature takes more time to encode the GIF)

Parameters
color32The Color to hide in the gif. Make sure the alpha value greater than Zero, else disable the transparent feature.
transparentColorRangeThe range of RGB value for picking nearby colors of the input color to set as transparent pixels.

◆ Setup() [1/2]

void ProGifRecorder.Setup ( bool  autoAspect,
int  width,
int  height,
int  fps,
float  recorderTime,
int  repeat,
int  quality 
)
inline

Initializes the component. Use this if you need to change the recorder settings in a script. This will flush the previously saved frames as settings can't be changed while recording.

Parameters
autoAspectAutomatically compute height from the current aspect ratio if True, force scale the gif size to width*height if False.
widthWidth in pixels
heightHeight in pixels
fpsRecording FPS
recorderTimeMaximum amount of seconds to record to memory
repeat-1: no repeat, 0: infinite, >0: repeat count
qualityQuality of color quantization (conversion of images to the maximum 256 colors allowed by the GIF specification). Lower values (minimum = 1) produce better colors, but slow processing significantly. Higher values will speed up the quantization pass at the cost of lower image quality (maximum = 100).

◆ Setup() [2/2]

void ProGifRecorder.Setup ( Vector2  gifAspectRatio,
int  width,
int  height,
int  fps,
float  recorderTime,
int  repeat,
int  quality 
)
inline

Initializes the component. Use this if you need to change the recorder settings in a script. This will flush the previously saved frames as settings can't be changed while recording. (Use this Setup if you need to crop the image to a specify aspect ratio. The pixels out of the provided aspect ratio will be cut.)

Parameters
gifAspectRatioImage ratio, 1:1, 16:9, 4:3, 3:2, etc. Use autoAspect if x or y of gifAspectRatio not greater than 0.
widthWidth.
heightHeight.
fpsFrames per second
recorderTimeMaximum amount of seconds to record to memory
repeat-1: no repeat, 0: infinite, >0: repeat count
qualityQuality of color quantization (conversion of images to the maximum 256 colors allowed by the GIF specification). Lower values (minimum = 1) produce better colors, but slow processing significantly. Higher values will speed up the quantization pass at the cost of lower image quality (maximum = 100).

The documentation for this class was generated from the following file: