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

Public Member Functions

void SetRecordSettings (bool autoAspect, int width, int height, float duration, int fps, int loop, int quality)
 (Settings-1) Sets the recording settings before StartRecord
 
void SetRecordSettings (Vector2 aspectRatio, int width, int height, float duration, int fps, int loop, int quality)
 (Settings-2) Sets the recording settings before StartRecord
 
void SetGifRotation (ImageRotator.Rotation rotation)
 Sets the GIF rotation.
 
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 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 StartRecord (Camera camera, string recorderName, Action< float > onRecordProgress=null, Action onRecordDurationMax=null, Action onPreProcessingDone=null, Action< int, float > onFileSaveProgress=null, Action< int, string > onFileSaved=null, bool autoClear=true)
 Create/Start a new recorder to store frames with specific camera.
 
ProGifRecorder GetRecorder (string recorderName)
 
void PauseRecord (string recorderName)
 
void ResumeRecord (string recorderName)
 
void StopRecord (string recorderName)
 
void SaveRecord (string recorderName, string fileNameWithoutExtension="")
 
void StopAndSaveRecord (string recorderName, string fileNameWithoutExtension="")
 
void ClearRecorder (string recorderName)
 
void ClearRecorder_Delay (string recorderName, string importingPlayerName, Action< string > onClear=null)
 
void PlayGif (ProGifRecorder recorderSource, Image playerImage, string playerName, Action< float > onLoading=null)
 Play gif from Recorder, display with Image.
 
void PlayGif (ProGifRecorder recorderSource, Renderer playerRenderer, string playerName, Action< float > onLoading=null)
 Play gif from Recorder, display with Renderer.
 
void PlayGif (ProGifRecorder recorderSource, RawImage playerRawImage, string playerName, Action< float > onLoading=null)
 Play gif from Recorder, display with RawImage.
 
void SetPlayerOnLoading (string playerName, Action< float > onLoading)
 Set the callback for checking the decode progress. If using a recorder source for playback, this becomes a loading-complete callback.
 
void SetPlayerOnFirstFrame (string playerName, Action< ProGifPlayerComponent.FirstGifFrame > onFirstFrame)
 Set the callback to be fired when the first gif frame ready. If using a recorder source for playback, this becomes a loading-complete callback with the first GIF frame returned.
 
void SetPlayerOnPlaying (string playerName, Action< GifTexture > onPlaying)
 Set the callback to be fired on every frame when playing gif.
 
ProGifPlayer GetPlayer (string playerName)
 
void PausePlayer (string playerName)
 
void ResumePlayer (string playerName)
 
void StopPlayer (string playerName)
 
void ClearPlayer (string playerName)
 

Static Public Member Functions

static void iSetRecordSettings (bool autoAspect, int width, int height, float duration, int fps, int loop, int quality)
 (Settings-1) Sets the recording settings before StartRecord
 
static void iSetRecordSettings (Vector2 aspectRatio, int width, int height, float duration, int fps, int loop, int quality)
 (Settings-2) Sets the recording settings before StartRecord
 
static void iSetGifRotation (ImageRotator.Rotation rotation)
 Sets the GIF rotation.
 
static void iSetTransparent (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)
 
static void iSetTransparent (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)
 
static void iStartRecord (Camera camera, string recorderName, Action< float > onRecordProgress=null, Action onRecordDurationMax=null, Action onPreProcessingDone=null, Action< int, float > onFileSaveProgress=null, Action< int, string > onFileSaved=null, bool autoClear=true)
 Create/Start a new recorder to store frames with specific camera.
 
static ProGifRecorder iGetRecorder (string recorderName)
 
static void iPauseRecord (string recorderName)
 
static void iResumeRecord (string recorderName)
 
static void iStopRecord (string recorderName)
 
static void iSaveRecord (string recorderName, string fileNameWithoutExtension="")
 
static void iStopAndSaveRecord (string recorderName, string fileNameWithoutExtension="")
 
static void iClearRecorder (string recorderName)
 Clear the target recorder immediately.
 
static void iClearRecorder_Delay (string recorderName, string importingPlayerName, Action< string > onClear=null)
 Delay clear the target recorder by monitoring both the recorder and the player status, this ensures the recorder textures not being cleared too early.
 
static void iSetPlayerOptimization (bool enable)
 
static void iPlayGif (ProGifRecorder recorderSource, Image playerImage, string playerName, Action< float > onLoading=null)
 Play gif from Recorder, display with Image.
 
static void iPlayGif (ProGifRecorder recorderSource, Renderer playerRenderer, string playerName, Action< float > onLoading=null)
 Play gif from Recorder, display with Renderer.
 
static ProGifPlayer iGetPlayer (string playerName)
 
static void iPausePlayer (string playerName)
 
static void iResumePlayer (string playerName)
 
static void iStopPlayer (string playerName)
 
static void iClearPlayer (string playerName)
 

Public Attributes

Vector2 m_AspectRatio = new Vector2(0, 0)
 
bool m_AutoAspect = true
 
int m_Width = 360
 
int m_Height = 360
 
float m_Duration = 3f
 
int m_Fps = 15
 
int m_Loop = 0
 
int m_Quality = 20
 
ImageRotator.Rotation m_Rotation = ImageRotator.Rotation.None
 
Color32 m_TransparentColor = new Color32(0, 0, 0, 0)
 
byte m_TransparentColorRange = 0
 
bool m_AutoTransparent = false
 
bool m_OptimizeMemoryUsage = true
 Set to 'true' to take advantage of the highly optimized ProGif playback solution for significantly save the memory usage.
 
Dictionary< string, ProGifRecorderm_GifRecorderDict = new Dictionary<string, ProGifRecorder>()
 
Dictionary< string, ProGifPlayerm_GifPlayerDict = new Dictionary<string, ProGifPlayer>()
 

Properties

static PGif Instance [get]
 Gets the instance of PGif. Create new one if no existing instance. Use this instance to control gif Record, Playback and Settings.
 
static bool HasInstance [get]
 

Member Function Documentation

◆ iClearRecorder_Delay()

static void PGif.iClearRecorder_Delay ( string  recorderName,
string  importingPlayerName,
Action< string >  onClear = null 
)
inlinestatic

Delay clear the target recorder by monitoring both the recorder and the player status, this ensures the recorder textures not being cleared too early.

Parameters
recorderNameThe recorder that to be saved to GIF file and also uses as a source for a gif player.
importingPlayerNameThe gif player uses for playing the recorder source.
onClearThe callback to be fired when the recorder actually being cleared. (Optional)

◆ iPlayGif() [1/2]

static void PGif.iPlayGif ( ProGifRecorder  recorderSource,
Image  playerImage,
string  playerName,
Action< float >  onLoading = null 
)
inlinestatic

Play gif from Recorder, display with Image.

Parameters
recorderSourceThe recorder which the gif frames are stored.
playerImageTarget image for displaying gif.
playerNameThe Name for identifying players in the dictionary.
onLoadingOn loading. Return value: loading progress(float)

◆ iPlayGif() [2/2]

static void PGif.iPlayGif ( ProGifRecorder  recorderSource,
Renderer  playerRenderer,
string  playerName,
Action< float >  onLoading = null 
)
inlinestatic

Play gif from Recorder, display with Renderer.

Parameters
recorderSourceThe recorder which the gif frames are stored.
playerRendererTarget renderer for displaying gif.
playerNameThe Name for identifying players in the dictionary.
onLoadingOn loading. Return value: loading progress(float)

◆ iSetGifRotation()

static void PGif.iSetGifRotation ( ImageRotator::Rotation  rotation)
inlinestatic

Sets the GIF rotation.

Parameters
rotationRotation: None, -90, 90, 180

◆ iSetPlayerOptimization()

static void PGif.iSetPlayerOptimization ( bool  enable)
inlinestatic

Set Enable or Disable for optimizing memory usage for gif players. (Call this method before playing GIF)

◆ iSetRecordSettings() [1/2]

static void PGif.iSetRecordSettings ( bool  autoAspect,
int  width,
int  height,
float  duration,
int  fps,
int  loop,
int  quality 
)
inlinestatic

(Settings-1) Sets the recording settings before StartRecord

Parameters
autoAspectIf set to true, auto aspect. Else force scale gif size to width*height.
widthWidth.
heightHeight. If autoAspect, height will be recalculated.
durationTotal time to record.
fpsFrames per second.
loopLoop. -1: no repeat, 0: infinite, >0: repeat count
qualityQuality. (1 - 100), 1: best, 100: faster

◆ iSetRecordSettings() [2/2]

static void PGif.iSetRecordSettings ( Vector2  aspectRatio,
int  width,
int  height,
float  duration,
int  fps,
int  loop,
int  quality 
)
inlinestatic

(Settings-2) Sets the recording settings before StartRecord

Parameters
aspectRatioA Specify aspect ratio for cropping gif. Set (0,0) if dont use, or use Settings-1 instead.
widthWidth.
heightHeight. If autoAspect, height will be recalculated.
durationTotal time to record.
fpsFrames per second.
loopLoop. -1: no repeat, 0: infinite, >0: repeat count
qualityQuality. (1 - 100), 1: best, 100: faster

◆ iSetTransparent() [1/2]

static void PGif.iSetTransparent ( bool  autoDetectTransparent)
inlinestatic

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.

◆ iSetTransparent() [2/2]

static void PGif.iSetTransparent ( Color32  color32,
byte  transparentColorRange 
)
inlinestatic

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.

◆ iStartRecord()

static void PGif.iStartRecord ( Camera  camera,
string  recorderName,
Action< float >  onRecordProgress = null,
Action  onRecordDurationMax = null,
Action  onPreProcessingDone = null,
Action< int, float >  onFileSaveProgress = null,
Action< int, string >  onFileSaved = null,
bool  autoClear = true 
)
inlinestatic

Create/Start a new recorder to store frames with specific camera.

Parameters
cameraThe target Camera to attach the newly create gif recroder.
recorderNameRecorder Name for identifying recorders in the dictionary.
onRecordProgressUpdate the record progress. Return values: record progress(float)
onRecordDurationMaxTo be fired when target duration frames reached.
onPreProcessingDoneOn pre processing done.
onFileSaveProgressOn file save progress. Retrun values: worker id(int), save progress(float).
onFileSavedOn file saved. Return values: id(int), saved path(string).
autoClearIf set to true, clear the recorder when gif saved. (Do Not auto clear the recorder if you want to preview the GIF)

◆ PlayGif() [1/3]

void PGif.PlayGif ( ProGifRecorder  recorderSource,
Image  playerImage,
string  playerName,
Action< float >  onLoading = null 
)
inline

Play gif from Recorder, display with Image.

Parameters
recorderSourceThe recorder which the gif frames are stored.
playerImageTarget image for displaying gif.
playerNameThe Name for identifying players in the dictionary.
onLoadingOn loading. Return value: loading progress(float)

◆ PlayGif() [2/3]

void PGif.PlayGif ( ProGifRecorder  recorderSource,
RawImage  playerRawImage,
string  playerName,
Action< float >  onLoading = null 
)
inline

Play gif from Recorder, display with RawImage.

Parameters
recorderSourceThe recorder which the gif frames are stored.
playerRawImageTarget RawImage for displaying gif.
playerNameThe Name for identifying players in the dictionary.
onLoadingOn loading. Return value: loading progress(float)

◆ PlayGif() [3/3]

void PGif.PlayGif ( ProGifRecorder  recorderSource,
Renderer  playerRenderer,
string  playerName,
Action< float >  onLoading = null 
)
inline

Play gif from Recorder, display with Renderer.

Parameters
recorderSourceThe recorder which the gif frames are stored.
playerRendererTarget renderer for displaying gif.
playerNameThe Name for identifying players in the dictionary.
onLoadingOn loading. Return value: loading progress(float)

◆ SetGifRotation()

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

Sets the GIF rotation.

Parameters
rotationRotation: None, -90, 90, 180

◆ SetPlayerOnFirstFrame()

void PGif.SetPlayerOnFirstFrame ( string  playerName,
Action< ProGifPlayerComponent::FirstGifFrame onFirstFrame 
)
inline

Set the callback to be fired when the first gif frame ready. If using a recorder source for playback, this becomes a loading-complete callback with the first GIF frame returned.

Parameters
onFirstFrameOn first frame callback, returns the first gifTexture and related data.

◆ SetPlayerOnLoading()

void PGif.SetPlayerOnLoading ( string  playerName,
Action< float >  onLoading 
)
inline

Set the callback for checking the decode progress. If using a recorder source for playback, this becomes a loading-complete callback.

Parameters
onLoadingOn loading callback, returns the decode/loading progress(float).

◆ SetPlayerOnPlaying()

void PGif.SetPlayerOnPlaying ( string  playerName,
Action< GifTexture onPlaying 
)
inline

Set the callback to be fired on every frame when playing gif.

Parameters
onPlayingOn gif playing callback, returns the current gifTexture.

◆ SetRecordSettings() [1/2]

void PGif.SetRecordSettings ( bool  autoAspect,
int  width,
int  height,
float  duration,
int  fps,
int  loop,
int  quality 
)
inline

(Settings-1) Sets the recording settings before StartRecord

Parameters
autoAspectIf set to true, auto aspect. Else force scale gif size to width*height.
widthWidth.
heightHeight. If autoAspect, height will be recalculated.
durationTotal time to record.
fpsFrames per second.
loopLoop. -1: no repeat, 0: infinite, >0: repeat count
qualityQuality. (1 - 100), 1: best, 100: faster

◆ SetRecordSettings() [2/2]

void PGif.SetRecordSettings ( Vector2  aspectRatio,
int  width,
int  height,
float  duration,
int  fps,
int  loop,
int  quality 
)
inline

(Settings-2) Sets the recording settings before StartRecord

Parameters
aspectRatioA Specify aspect ratio for cropping gif. Set (0,0) if dont use, or use Settings-1 instead.
widthWidth.
heightHeight. If autoAspect, height will be recalculated.
durationTotal time to record.
fpsFrames per second.
loopLoop. -1: no repeat, 0: infinite, >0: repeat count
qualityQuality. (1 - 100), 1: best, 100: faster

◆ SetTransparent() [1/2]

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

◆ StartRecord()

void PGif.StartRecord ( Camera  camera,
string  recorderName,
Action< float >  onRecordProgress = null,
Action  onRecordDurationMax = null,
Action  onPreProcessingDone = null,
Action< int, float >  onFileSaveProgress = null,
Action< int, string >  onFileSaved = null,
bool  autoClear = true 
)
inline

Create/Start a new recorder to store frames with specific camera.

Parameters
cameraThe target Camera to attach the newly create gif recroder.
recorderNameRecorder Name for identifying recorders in the dictionary.
onRecordProgressUpdate the record progress. Return values: record progress(float)
onRecordDurationMaxTo be fired when target duration frames reached.
onPreProcessingDoneOn pre processing done.
onFileSaveProgressOn file save progress. Retrun values: worker id(int), save progress(float).
onFileSavedOn file saved. Return values: id(int), saved path(string).
autoClearIf set to true Clear the recorder when gif saved? (Do Not auto clear the recorder if you want to preview the GIF)

Property Documentation

◆ Instance

PGif PGif.Instance
staticget

Gets the instance of PGif. Create new one if no existing instance. Use this instance to control gif Record, Playback and Settings.

The instance.


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