Megacool Unity
TheUnityinterfacetotheMegacoolSDK
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Megacool Class Reference

This is the main interface to the Megacool SDK. Call Start() as early as possible during application startup. More...

Public Types

enum  GifColorTableType { GifColorTableType.GifColorTableFixed, GifColorTableType.GifColorTableAnalyzeFirst, GifColorTableType.GifColorTableDynamic }
 How the colors in the GIF should be computed. More...
 

Public Member Functions

void Start ()
 Initialize the SDK. More...
 
void StartRecording ()
 Start recording a GIF More...
 
void StartRecording (MegacoolRecordingConfig config)
 Start customized GIF recording. More...
 
void RegisterScoreChange ()
 Note an event for highlight recording. More...
 
void RegisterScoreChange (int scoreDelta)
 Note a change in score for highlight recording More...
 
void CaptureFrame ()
 Capture a single frame. More...
 
void CaptureFrame (MegacoolRecordingConfig config)
 Capture a single frame. More...
 
void CaptureFrame (MegacoolRecordingConfig config, bool forceAdd)
 Capture a single frame. More...
 
void PauseRecording ()
 Pauses the recording. More...
 
void StopRecording ()
 Stops the recording. Calling CaptureFrame or StartRecording after this will cause a new recording to be started. More...
 
void DeleteRecording (string recordingId)
 Delete a recording More...
 
int GetNumberOfFrames (string recordingId)
 Gets the number of frames available in a given recording. More...
 
void GetShares (Action< List< MegacoolShare >> shares)
 Get the state of shares sent. More...
 
void DeleteShares (Func< MegacoolShare, bool > filter)
 Deletes local shares. More...
 
void Share ()
 Share the default recording. More...
 
void Share (MegacoolShareConfig config)
 Share a recording according to the config. More...
 
void ShareToMessenger ()
 Share directly to Facebook Messenger. More...
 
void ShareToMessenger (MegacoolShareConfig config)
 Share directly to Facebook Messenger with custom config. More...
 
void ShareToTwitter ()
 Share directly to Twitter. More...
 
void ShareToTwitter (MegacoolShareConfig config)
 Share directly to Twitter with custom config. More...
 
void ShareToMessages ()
 Share directly to SMS. More...
 
void ShareToMessages (MegacoolShareConfig config)
 Share directly to SMS with custom config. More...
 
void ShareToMail ()
 Share directly to email with custom config. More...
 
void ShareToMail (MegacoolShareConfig config)
 Share directly to email with custom config. More...
 
void SubmitDebugData (string message)
 Submit debug data from the SDK to the developers to assist in fixing bugs. More...
 
void ResetIdentity ()
 Resets the device identity. More...
 

Public Attributes

Action CompletedSharing
 Callback when a user has completed a share. On Android this is only available for API level 22+. More...
 
Action DismissedSharing
 Callback when a user has aborted (dismissed) a share. On Android this is only available for API level 22+. More...
 
Action PossiblyCompletedSharing
 Callback when a user either aborted or completed a share, but we can't know which. More...
 

Static Public Attributes

static Action< List< MegacoolEvent > > OnMegacoolEvents = delegate {}
 Listen to all events emitted by the SDK. Everything sent here will also be sent to the dedicated per-event listeners. More...
 
static Action< MegacoolEventOnReceivedShareOpened = delegate {}
 Listen to received share opened events. More...
 
static Action< MegacoolEventOnLinkClicked = delegate {}
 Listen to link click events. This is what you should use for navigation within your app if you implement deep linking. More...
 
static Action< MegacoolEventOnSentShareOpened = delegate {}
 Listen to sent share opened events. More...
 
static double ScaleFactor
 The scale factor to use for the encoded media. More...
 

Properties

static Megacool Instance [get]
 Gets the instance. More...
 
MegacoolRecordingConfig DefaultRecordingConfig [set]
 The default recording config. Will be merged with the config given to CaptureFrame or StartRecording, if any. More...
 
MegacoolShareConfig DefaultShareConfig [set]
 The default share config. Will be merged with the config given to Share, if any. More...
 
GifColorTableType GifColorTable [set]
 Set the type of GIF color table to use. More...
 
static bool Debug [get, set]
 Turn on / off debug mode. In debug mode calls to the SDK are stored and can be submitted to the core developers using SubmitDebugData later. More...
 
bool KeepCompletedRecordings [set]
 Whether to keep completed recordings around. More...
 
MegacoolCaptureMethod CaptureMethod [get, set]
 Set how frames should be captured. More...
 

Detailed Description

This is the main interface to the Megacool SDK. Call Start() as early as possible during application startup.

Member Enumeration Documentation

◆ GifColorTableType

How the colors in the GIF should be computed.

Enumerator
GifColorTableFixed 

A fixed set of colors is used. This is very fast, but sacrifices quality for nuanced colors and gradients.

GifColorTableAnalyzeFirst 

Analyze the frames first. This algorithm is largely equivalent to dynamic, but uses a bit more memory. Which is faster depends on workload.

This is only available on iOS, on Android this is the same as dynamic.

GifColorTableDynamic 

A subset of the frames is analyzed first. This is the default and yields a good balance between quality and speed.

Member Function Documentation

◆ CaptureFrame() [1/3]

void Megacool.CaptureFrame ( )
inline

Capture a single frame.

◆ CaptureFrame() [2/3]

void Megacool.CaptureFrame ( MegacoolRecordingConfig  config)
inline

Capture a single frame.

If the recording doesn't already exist it'll be created with the settings specified in the config.

Parameters
configthe configuration to use to create the recording, if it doesn't already exist.

◆ CaptureFrame() [3/3]

void Megacool.CaptureFrame ( MegacoolRecordingConfig  config,
bool  forceAdd 
)
inline

Capture a single frame.

If the recording doesn't already exist it'll be created with the settings specified in the config.

Parameters
configthe configuration to use to create the recording, if it doesn't already exist.
forceAddSet to true to ensure the frame is included in the recording, even if the overflow strategy otherwise would skip it. Useful for timelapse to include the last frame with a score board or final state.

◆ DeleteRecording()

void Megacool.DeleteRecording ( string  recordingId)
inline

Delete a recording

Will remove any frames of the recording in memory and on disk. Both completed and incomplete recordings will take space on disk, thus particularly if you're using KeepCompletedRecordings = true you might want to provide an interface to your users for removing recordings they don't care about anymore to free up space for new recordings.

Parameters
recordingIdRecording identifier.

◆ DeleteShares()

void Megacool.DeleteShares ( Func< MegacoolShare, bool >  filter)
inline

Deletes local shares.

Use this to clear old shares from local storage. The filter will be passed each share available locally, return true for the given share to be deleted.

Parameters
filterFilter.

◆ GetNumberOfFrames()

int Megacool.GetNumberOfFrames ( string  recordingId)
inline

Gets the number of frames available in a given recording.

If you're sanity checking a preview you should call MegacoolGifPreview.GetNumberOfFrames() after calling MegacoolGifPreview.StartPreview() instead as it's less racy, to get the count for other uses you can use this method.

Returns
The number of frames.
Parameters
recordingIdWhich recording to get the frame count of

◆ GetShares()

void Megacool.GetShares ( Action< List< MegacoolShare >>  shares)
inline

Get the state of shares sent.

Use this if a user is wondering whether someone has clicked, installed or been re-engaged from the shares sent.

This will also cause the SDK to check for new events, so you might receive MegacoolSentShareOpened events after calling this.

Parameters
sharesCallback to receive the updated shares

◆ PauseRecording()

void Megacool.PauseRecording ( )
inline

Pauses the recording.

This does nothing if there's no recording currently in progress.

◆ RegisterScoreChange() [1/2]

void Megacool.RegisterScoreChange ( )
inline

Note an event for highlight recording.

For highlight recording use only. Call this function when something interesting occurs, like a point is scored or a coin collected or the player hits an opponent. The section of the recording with the highest amount of calls to this function will be what is present in the final recording, with the peak located at located at Megacool.PeakLocation.

◆ RegisterScoreChange() [2/2]

void Megacool.RegisterScoreChange ( int  scoreDelta)
inline

Note a change in score for highlight recording

For highlight recording use only. Call this function when something interesting occurs, like a point is scored or a coin collected or the player hits an opponent. The section of the recording with the highest absolute sum of deltas sent to this function will be what is present in the final recording, with the peak located at located at Megacool.PeakLocation.

◆ ResetIdentity()

void Megacool.ResetIdentity ( )
inline

Resets the device identity.

This is a test or debugging tool to make the current device appear as if it's a new device, making it possible to test referrals and link clicks from a "new" device.

Must be called before Start().

◆ Share() [1/2]

void Megacool.Share ( )
inline

Share the default recording.

◆ Share() [2/2]

void Megacool.Share ( MegacoolShareConfig  config)
inline

Share a recording according to the config.

Parameters
configConfig.

◆ ShareToMail() [1/2]

void Megacool.ShareToMail ( )
inline

Share directly to email with custom config.

Parameters
configConfig.

◆ ShareToMail() [2/2]

void Megacool.ShareToMail ( MegacoolShareConfig  config)
inline

Share directly to email with custom config.

Parameters
configConfig.

◆ ShareToMessages() [1/2]

void Megacool.ShareToMessages ( )
inline

Share directly to SMS.

Parameters
configConfig.

◆ ShareToMessages() [2/2]

void Megacool.ShareToMessages ( MegacoolShareConfig  config)
inline

Share directly to SMS with custom config.

Parameters
configConfig.

◆ ShareToMessenger() [1/2]

void Megacool.ShareToMessenger ( )
inline

Share directly to Facebook Messenger.

Parameters
configConfig.

◆ ShareToMessenger() [2/2]

void Megacool.ShareToMessenger ( MegacoolShareConfig  config)
inline

Share directly to Facebook Messenger with custom config.

Parameters
configConfig.

◆ ShareToTwitter() [1/2]

void Megacool.ShareToTwitter ( )
inline

Share directly to Twitter.

Parameters
configConfig.

◆ ShareToTwitter() [2/2]

void Megacool.ShareToTwitter ( MegacoolShareConfig  config)
inline

Share directly to Twitter with custom config.

Parameters
configConfig.

◆ Start()

void Megacool.Start ( )
inline

Initialize the SDK.

To listen for events for the SDK, make sure you register the delegates for OnLinkClicked/OnReceivedShareOpened and similar before calling this.

◆ StartRecording() [1/2]

void Megacool.StartRecording ( )
inline

Start recording a GIF

This will keep a buffer of 50 frames (default). The frames are overwritten until StopRecording gets called.

◆ StartRecording() [2/2]

void Megacool.StartRecording ( MegacoolRecordingConfig  config)
inline

Start customized GIF recording.

This will keep a buffer of 50 frames (default). The frames are overwritten until StopRecording gets called.

Parameters
configConfig to customize the recording.

◆ StopRecording()

void Megacool.StopRecording ( )
inline

Stops the recording. Calling CaptureFrame or StartRecording after this will cause a new recording to be started.

If KeepCompletedRecordings is set to true (default is false), the recording will still be available on disk and can be shared and/or previewed later, and you have to manually call DeleteRecording when you want to clear it from disk. With the default setting it'll be deleted automatically when a new recording is started.

◆ SubmitDebugData()

void Megacool.SubmitDebugData ( string  message)
inline

Submit debug data from the SDK to the developers to assist in fixing bugs.

If something in the SDK is not behaving as expected, set Debug=true as early as possible (preferably before Start()), after the problem has been observed call this method with a descriptive message. The developers will then receive logs and other debugging information from the device to assist in debugging.

Parameters
messageBrief summary of what you expected to happen and what happened

Member Data Documentation

◆ CompletedSharing

Action Megacool.CompletedSharing
Initial value:
= delegate {
}

Callback when a user has completed a share. On Android this is only available for API level 22+.

Megacool.Instance.CompletedSharing += () => { Debug.Log("User completed sharing"); }

◆ DismissedSharing

Action Megacool.DismissedSharing
Initial value:
= delegate {
}

Callback when a user has aborted (dismissed) a share. On Android this is only available for API level 22+.

Megacool.Instance.DismissedSharing += () => { Debug.Log("User dismissed sharing"); }

◆ OnLinkClicked

Action<MegacoolEvent> Megacool.OnLinkClicked = delegate {}
static

Listen to link click events. This is what you should use for navigation within your app if you implement deep linking.

This event does not rely on network connectivity and is thus very fast and always available, but that also means the data will not necessarily be valid. Use the url in the event for navigation, but wait for the MegacoolReceivedShareOpened event if you need a verified userId or share data.

When the app is installed the first time from a referral on iOS you will not receive this event, you have to use OnReceivedShareOpened to handle that.

NB: Must be registered before calling Start() to ensure all events are received correctly.

◆ OnMegacoolEvents

Action<List<MegacoolEvent> > Megacool.OnMegacoolEvents = delegate {}
static

Listen to all events emitted by the SDK. Everything sent here will also be sent to the dedicated per-event listeners.

NB: Must be registered before calling Start() to ensure all events are received correctly.

◆ OnReceivedShareOpened

Action<MegacoolEvent> Megacool.OnReceivedShareOpened = delegate {}
static

Listen to received share opened events.

These events are emitted when this device clicks on a share sent by someone else. Use the IsFirstSession attribute on the event to determine whether the device installed the app from the share.

NB: Must be registered before calling Start() to ensure all events are received correctly.

◆ OnSentShareOpened

Action<MegacoolEvent> Megacool.OnSentShareOpened = delegate {}
static

Listen to sent share opened events.

This is the primary event to use if you want to reward a user for generating installs, which you can tell from the IsFirstSession attribute on the event.

◆ PossiblyCompletedSharing

Action Megacool.PossiblyCompletedSharing
Initial value:
= delegate {
}

Callback when a user either aborted or completed a share, but we can't know which.

This is only called on Android, where we cannot always tell whether the share actually completed or not.

◆ ScaleFactor

double Megacool.ScaleFactor
static

The scale factor to use for the encoded media.

The default is 0.5 for screens whose longest side is < 1500 in length, or 0.25 for anything larger. If the resulting dimensions are less than 200 for either width or height, then the scale factor is increased to ensure a minimum of 200 or more in both dimensions. By passing in a value for ScaleFactor, you override this behavior. It's important to keep in mind that while a larger scale factor will produce encoded media with a higher resolution, it will make captures and encoding slower, and also increase the size of the encoded media, which will increase both disk and network usage. In any case, we will round up the scaled dimensions to be divisible by 16, as this is a requirement for many MP4 encoders.

Property Documentation

◆ CaptureMethod

MegacoolCaptureMethod Megacool.CaptureMethod
getset

Set how frames should be captured.

The capture method.

◆ Debug

bool Megacool.Debug
staticgetset

Turn on / off debug mode. In debug mode calls to the SDK are stored and can be submitted to the core developers using SubmitDebugData later.

true if debug mode; otherwise, false.

◆ DefaultRecordingConfig

MegacoolRecordingConfig Megacool.DefaultRecordingConfig
set

The default recording config. Will be merged with the config given to CaptureFrame or StartRecording, if any.

Note that even though the object is mutable changes will NOT be applied without the config being set again. This also doesn't impact already started recordings.

Usage:

FrameRate = 15,
MaxFrames = 75,
};

Or, to modify it later:

◆ DefaultShareConfig

MegacoolShareConfig Megacool.DefaultShareConfig
set

The default share config. Will be merged with the config given to Share, if any.

◆ GifColorTable

GifColorTableType Megacool.GifColorTable
set

Set the type of GIF color table to use.

This only has any effect when sharing to apps where .gif gives a better experience than mp4. Try sharing to email or messages to see the impact of this.

The gif color table type

◆ Instance

Megacool Megacool.Instance
staticget

Gets the instance.

The instance.

◆ KeepCompletedRecordings

bool Megacool.KeepCompletedRecordings
set

Whether to keep completed recordings around.

The default is false, which means that all completed recordings will be deleted whenever a new recording is started with either captureFrame or startRecording. Setting this to true means we will never delete a completed recording, which is what you want if you want to enable player to browse previous GIFs they've created. A completed recording will still be overwritten if a new recording is started with the same recordingId.

true to keep completed recordings; otherwise, false.


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