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

Public Types

enum  CommonColorEnum {
  White = 0 , Black , Blue , Green ,
  Red , LightYellow
}
 

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 StartRecord (Action< float > onRecordProgress=null, Action onRecordDurationMax=null, bool autoClear=true)
 Starts the recorder to store frames with Camera.main. (For changing recorder settings, you can use the SetRecordSettings method before calling StartRecord)
 
void StartRecord (Camera camera, Action< float > onRecordProgress=null, Action onRecordDurationMax=null, bool autoClear=true)
 Starts the recorder to store frames with specific camera. (For changing recorder settings, you can use the SetRecordSettings method before calling 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 PauseRecord ()
 Pauses the recorder.
 
void ResumeRecord ()
 Resume the recorder.
 
void StopRecord ()
 Stops the recorder.
 
void SaveRecord (Action onRecorderPreProcessingDone=null, Action< int, float > onFileSaveProgress=null, Action< int, string > onFileSaved=null, string fileNameWithoutExtension="")
 Saves the stored frames to a gif file.
 
void StopAndSaveRecord (Action onRecorderPreProcessingDone=null, Action< int, float > onFileSaveProgress=null, Action< int, string > onFileSaved=null, string fileNameWithoutExtension="")
 Stops the recorder and saves the stored frames to a gif file.
 
void SetPlayerOptimization (bool enable)
 
void PlayGif (Image playerImage, Action< float > onLoading=null)
 Play gif from Recorder, display with Image.
 
void PlayGif (Renderer playerRenderer, Action< float > onLoading=null)
 Play gif from Recorder, display with Renderer.
 
void PlayGif (RawImage playerRawImage, Action< float > onLoading=null)
 Play gif from Recorder, display with RawImage.
 
void SetPlayerOnLoading (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 (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 (Action< GifTexture > onPlaying)
 Set the callback to be fired on every frame when playing gif.
 
void PausePlayer ()
 
void ResumePlayer ()
 
void StopPlayer ()
 
void ShareTwitter (string filePath)
 Twitter share example.
 
void ShareTwitter_Mobile (string filePath)
 Twitter mobile share example.
 
void ShareFacebook (string filePath="")
 Facebook share example.
 
void Clear ()
 
void ClearRecorder ()
 
void ClearRecorder_Delay (Action 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.
 
void ClearPlayer ()
 

Static Public Member Functions

static T InstantiatePrefab< T > (GameObject prefab)
 
static Color GetColor (CommonColorEnum colorEnum)
 

Public Attributes

string m_GiphyUserName = ""
 
string m_GiphyApiKey = ""
 
string m_GiphyUploadApiKey = ""
 
ProGifRecorder m_GifRecorder = null
 
ProGifPlayer m_GifPlayer = null
 
string m_CurrentGifPath = ""
 
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.
 

Static Public Attributes

static string PP_LastGifPathKey = "ProGIF_LastGifPathKey"
 

Properties

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

Member Function Documentation

◆ ClearRecorder_Delay()

void ProGifManager.ClearRecorder_Delay ( Action  onClear = null)
inline

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
onClearThe callback to be fired when the recorder actually being cleared. (Optional)

◆ InstantiatePrefab< T >()

static T ProGifManager.InstantiatePrefab< T > ( GameObject  prefab)
inlinestatic
Type Constraints
T :MonoBehaviour 

◆ PlayGif() [1/3]

void ProGifManager.PlayGif ( Image  playerImage,
Action< float >  onLoading = null 
)
inline

Play gif from Recorder, display with Image.

Parameters
playerImageTarget image for displaying gif.
onLoadingOn loading. Return value: loading progress(float)

◆ PlayGif() [2/3]

void ProGifManager.PlayGif ( RawImage  playerRawImage,
Action< float >  onLoading = null 
)
inline

Play gif from Recorder, display with RawImage.

Parameters
playerRawImageTarget RawImage for displaying gif.
onLoadingOn loading. Return value: loading progress(float)

◆ PlayGif() [3/3]

void ProGifManager.PlayGif ( Renderer  playerRenderer,
Action< float >  onLoading = null 
)
inline

Play gif from Recorder, display with Renderer.

Parameters
playerRendererTarget renderer for displaying gif.
onLoadingOn loading. Return value: loading progress(float)

◆ SaveRecord()

void ProGifManager.SaveRecord ( Action  onRecorderPreProcessingDone = null,
Action< int, float >  onFileSaveProgress = null,
Action< int, string >  onFileSaved = null,
string  fileNameWithoutExtension = "" 
)
inline

Saves the stored frames to a gif file.

Parameters
onRecorderPreProcessingDoneOn recorder 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).

◆ SetGifRotation()

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

Sets the GIF rotation.

Parameters
rotationRotation: None, -90, 90, 180

◆ SetPlayerOnFirstFrame()

void ProGifManager.SetPlayerOnFirstFrame ( 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 ProGifManager.SetPlayerOnLoading ( 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 progress(float).

◆ SetPlayerOnPlaying()

void ProGifManager.SetPlayerOnPlaying ( 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.

◆ SetPlayerOptimization()

void ProGifManager.SetPlayerOptimization ( bool  enable)
inline

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

◆ SetRecordSettings() [1/2]

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

◆ ShareFacebook()

void ProGifManager.ShareFacebook ( string  filePath = "")
inline

Facebook share example.

Parameters
filePathFile path.

◆ ShareTwitter()

void ProGifManager.ShareTwitter ( string  filePath)
inline

Twitter share example.

Parameters
filePathFile path.

◆ ShareTwitter_Mobile()

void ProGifManager.ShareTwitter_Mobile ( string  filePath)
inline

Twitter mobile share example.

Parameters
filePathFile path.

◆ StartRecord() [1/2]

void ProGifManager.StartRecord ( Action< float >  onRecordProgress = null,
Action  onRecordDurationMax = null,
bool  autoClear = true 
)
inline

Starts the recorder to store frames with Camera.main. (For changing recorder settings, you can use the SetRecordSettings method before calling StartRecord)

Parameters
onRecordProgressUpdate the record progress. Return values: record progress(float)
onRecordDurationMaxTo be fired when target duration frames reached.
autoClearIf set to true, clear the recorder when gif saved. (Do Not auto clear the recorder if you want to preview the GIF)

◆ StartRecord() [2/2]

void ProGifManager.StartRecord ( Camera  camera,
Action< float >  onRecordProgress = null,
Action  onRecordDurationMax = null,
bool  autoClear = true 
)
inline

Starts the recorder to store frames with specific camera. (For changing recorder settings, you can use the SetRecordSettings method before calling StartRecord)

Parameters
cameraTarget Camera for recording gif
onRecordProgressUpdate the record progress. Return values: record progress(float)
onRecordDurationMaxTo be fired when target duration frames reached.
autoClearIf set to true Clear the recorder when gif saved? (Do Not auto clear the recorder if you want to preview the GIF)

◆ StopAndSaveRecord()

void ProGifManager.StopAndSaveRecord ( Action  onRecorderPreProcessingDone = null,
Action< int, float >  onFileSaveProgress = null,
Action< int, string >  onFileSaved = null,
string  fileNameWithoutExtension = "" 
)
inline

Stops the recorder and saves the stored frames to a gif file.

Parameters
onRecorderPreProcessingDoneOn recorder 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).

Property Documentation

◆ Instance

ProGifManager ProGifManager.Instance
staticget

Gets the instance of ProGifManager. 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: