My Project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Properties | Events | List of all members
ProGifRecorderComponent Class Reference
Inheritance diagram for ProGifRecorderComponent:

Public Types

enum  EncodePlayMode { Normal = 0 , Reverse , PingPong }
 

Public Member Functions

void SetOnRecordAction (Action< float > onRecordAction)
 
void SetScaleAndOffset (Vector2 scale, Vector2 offset)
 
void ForceSetFrames (Queue< RenderTexture > renderTextures)
 Force assign frames(RenderTexture) to this recorder. This will clear all previous stored frames first.
 
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.)
 
void SetOverrideQuality (int quality)
 Sets the GIF images encoding quality, you should set this value before start to Save the GIF. (Quality 1 = best, 100 = fastest)
 
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 for encoding 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 encoding the GIF)
 
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 Pause ()
 Pauses recording.
 
void Resume ()
 Resumes recording. You can't resume while it's pre-processing data to be saved.
 
void Record (Action onDurationEnd=null)
 Starts or resumes recording. You can't start or 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.
 
bool HasRecorded ()
 
void ComputeHeight ()
 
void ClearAndRemoveScript ()
 Clear and Remove this script from camera.
 

Public Attributes

Action onDurationEnd = null
 
ThreadPriority m_WorkerPriority = ThreadPriority.BelowNormal
 Sets the worker threads priority. This will only affect newly created threads.
 
ImageRotator.Rotation m_Rotation = ImageRotator.Rotation.None
 
EncodePlayMode m_EncodePlayMode = EncodePlayMode.Normal
 The playback mode for encoding frames to GIF file. Available modes including Forward, Backward and Ping-pong mode, Ping-pong mode will double the frames in the created GIF file.
 
int m_AntiAliasingLevel = 1
 The anti-aliasing level for SRP project(URP, LWRP, HDRP) or RENDER_PLUS mode. Valid value: 1 = OFF, 2, 4, 8 = Best quality but Heaviest. (To enable this setting, please insert the define symbol 'SDEV_RENDER_PLUS' or 'PRO_GIF_SRP' in the Scripting Define Symbols field of Unity PlayerSettings)
 
int m_MaxNumberOfThreads = 0
 Limits the number of threads for encoding the GIF. Less or equals 0: use all the CPU threads. (To check the max threads support on the current device, use UnityEngine.SystemInfo.processorCount)
 
bool m_IgnoreTimeScale = true
 Affects the frames capture interval in the camera rendering methods.
 

Properties

ProGifRecorder.RecorderState State [get]
 Current state of the recorder.
 
string SaveFolder [get, set]
 The folder to save the gif to. No trailing slash.
 
float EstimatedMemoryUse [get]
 Returns the estimated VRam used (in MB) for recording. This is not the storage file size. The storage file size can be retrieved with FileInfo after saved.
 
int Width [get]
 
int Height [get]
 
bool IsCustomRatio [get]
 
float RecordProgress [get]
 
int FPS [get]
 
Queue< RenderTexture > Frames [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 ProGifRecorderComponent.ForceSetFrames ( Queue< RenderTexture >  renderTextures)
inline

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

Parameters
renderTexturesRenderTexture list(FIFO).

◆ Save() [1/2]

void ProGifRecorderComponent.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 ProGifRecorderComponent.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 ProGifRecorderComponent.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 ProGifRecorderComponent.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

◆ SetOverrideFrameDelay()

void ProGifRecorderComponent.SetOverrideFrameDelay ( float  frameDelayInSeconds)
inline

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

  • Change during/after PreProcessing state will not be applied.

◆ SetTransparent() [1/2]

void ProGifRecorderComponent.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 encoding 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 ProGifRecorderComponent.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 for encoding 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 ProGifRecorderComponent.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
widthWidth in pixels
heightHeight in pixels
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).

◆ Setup() [2/2]

void ProGifRecorderComponent.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: