Megacool Unity
The Unity interface to the Megacool SDK
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 class  GifColorTableType { GifColorTableFixed , GifColorTableAnalyzeFirst , 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...
 
int GetRecordingScore (string recordingId)
 Get the total score for the given recording. More...
 
void GetUserId (Action< string > callback)
 Get the user identifier. If already known the callback is called immediately, otherwise it's called once we communicate with the backend and learn the id. After that it's stored locally. 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 ShareScreenshot (MegacoolRecordingConfig recordingConfig=null, MegacoolShareConfig shareConfig=null)
 Take a screenshot and share it immediately. 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...
 
Action< MegacoolLinkClickedEventLinkClicked
 Callback when a link click was detected. Use this for navigation within the app. More...
 
Action< MegacoolReceivedShareOpenedEventReceivedShareOpened
 Callback when the user clicks on someone else's share. More...
 
Action< MegacoolSentShareOpenedEventSentShareOpened
 Callback when a share sent by the user was clicked on by someone else. More...
 

Static Public Attributes

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, or -1 if the recording doesn't exist
Parameters
recordingIdWhich recording to get the frame count of

◆ GetRecordingScore()

int Megacool.GetRecordingScore ( string  recordingId)
inline

Get the total score for the given recording.

By observing this value you can learn what scores are average and which are good in your game, and use this to only prompt the user to share if it was a high-scoring recording, or promote high-scoring recordings in the game or use it to set the share text.

The score will be 0 if the recording doesn't use the highlight overflow strategy, or if RegisterScoreChange has never been called.

Returns
The score for the given recording, or -1 if the recording couldn't be found.
Parameters
recordingIdThe recording to fetch the score for. Fetches the default if null.

◆ 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

◆ GetUserId()

void Megacool.GetUserId ( Action< string >  callback)
inline

Get the user identifier. If already known the callback is called immediately, otherwise it's called once we communicate with the backend and learn the id. After that it's stored locally.

◆ 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.

◆ ShareScreenshot()

void Megacool.ShareScreenshot ( MegacoolRecordingConfig  recordingConfig = null,
MegacoolShareConfig  shareConfig = null 
)
inline

Take a screenshot and share it immediately.

This is a helper around captureFrame(View) and share(Activity) when you only need to share a screenshot and not all the other bells and whistles for recordings.

This method is functionally equivalent to: Megacool.Instance.PauseRecording(); string tempRecording = "random-unused-id"; Megacool.Instance.CaptureFrame(new MegacoolRecordingConfig { RecordingId = tempRecordingId, MaxFrames = 1, }); Megacool.Instance.Share(new MegacoolShareConfig { RecordingId = tempRecordingId, }); Megacool.Instance.DeleteRecording(tempRecordingId); Note that if this method is called while a recording is underway the screenshot is likely to be missing from the share. To stay on the safe side, leave a couple hundred ms between stopping a recording and sharing a screenshot.

Parameters
recordingConfigThe recording config, or null. Most properties don't apply to screenshots, but the last frame overlay does.
shareConfigThe share config, or null.

◆ ShareToMail() [1/2]

void Megacool.ShareToMail ( )
inline

Share directly to email with custom config.

◆ 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.

◆ ShareToMessages() [2/2]

void Megacool.ShareToMessages ( MegacoolShareConfig  config)
inline

Share directly to SMS 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 Megacool.Instance.LinkClicked/Megacool.Instance.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

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

Please note that this isn't super reliable as the app that is being shared to has to correctly implement the sharing API provided by the OS for us to detect this correctly. On Android most apps don't report the outcome of the share at all, leading to PossiblyCompletedSharing being called most of the time. On iOS most apps report this correctly, but some apps will cause this to be called even if the share was dismissed, while other apps might cause DismissedSharing to be called even if the share was actually completed.

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

◆ DismissedSharing

Action Megacool.DismissedSharing

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

Please note that this isn't super reliable as the app that is being shared to has to correctly implement the sharing API provided by the OS for us to detect this correctly. On Android most apps don't report the outcome of the share at all, leading to PossiblyCompletedSharing being called most of the time. On iOS most apps report this correctly, but some apps will cause this to be called even if the share was completed, while other apps might cause CompletedSharing to be called even if the share was actually dismissed.

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

◆ LinkClicked

Action<MegacoolLinkClickedEvent> Megacool.LinkClicked

Callback when a link click was detected. Use this for navigation within the app.

See also
MegacoolLinkClickedEvent

◆ PossiblyCompletedSharing

Action Megacool.PossiblyCompletedSharing

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

This is currently only called on Android, but note that detecting share outcome isn't super reliable on either platform. On iOS most apps report share outcome correctly.

◆ ReceivedShareOpened

Action<MegacoolReceivedShareOpenedEvent> Megacool.ReceivedShareOpened

Callback when the user clicks on someone else's share.

See also
MegacoolReceivedShareOpenedEvent

◆ 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.

◆ SentShareOpened

Action<MegacoolSentShareOpenedEvent> Megacool.SentShareOpened

Callback when a share sent by the user was clicked on by someone else.

See also
MegacoolSentShareOpenedEvent

Property Documentation

◆ CaptureMethod

MegacoolCaptureMethod Megacool.CaptureMethod
getset

Set how frames should be captured.

◆ 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,
};
This is the main interface to the Megacool SDK. Call Start() as early as possible during application ...
Definition: Megacool.cs:37
static Megacool Instance
Gets the instance.
Definition: Megacool.cs:90
MegacoolRecordingConfig DefaultRecordingConfig
The default recording config. Will be merged with the config given to CaptureFrame or StartRecording,...
Definition: Megacool.cs:205
Pass to Megacool.StartRecording to configure how recordings are made.
Definition: MegacoolRecordingConfig.cs:4

Or, to modify it later:

config.MaxFrames = 150;
int?? MaxFrames
Set the max number of frames in a recording. If set to 1 the recording will be shared as a still imag...
Definition: MegacoolRecordingConfig.cs:55

◆ 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: