Megacool Unity
TheUnityinterfacetotheMegacoolSDK
|
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< MegacoolEvent > | OnReceivedShareOpened = delegate {} |
Listen to received share opened events. More... | |
static Action< MegacoolEvent > | OnLinkClicked = 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< MegacoolEvent > | OnSentShareOpened = 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... | |
This is the main interface to the Megacool SDK. Call Start()
as early as possible during application startup.
|
strong |
How the colors in the GIF should be computed.
|
inline |
Capture a single frame.
|
inline |
Capture a single frame.
If the recording doesn't already exist it'll be created with the settings specified in the config.
config | the configuration to use to create the recording, if it doesn't already exist. |
|
inline |
Capture a single frame.
If the recording doesn't already exist it'll be created with the settings specified in the config.
config | the configuration to use to create the recording, if it doesn't already exist. |
forceAdd | Set 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. |
|
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.
recordingId | Recording identifier. |
|
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.
filter | Filter. |
|
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.
recordingId | Which recording to get the frame count of |
|
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.
shares | Callback to receive the updated shares |
|
inline |
Pauses the recording.
This does nothing if there's no recording currently in progress.
|
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.
|
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.
|
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().
|
inline |
Share the default recording.
|
inline |
Share a recording according to the config.
config | Config. |
|
inline |
Share directly to email with custom config.
config | Config. |
|
inline |
Share directly to email with custom config.
config | Config. |
|
inline |
Share directly to SMS.
config | Config. |
|
inline |
Share directly to SMS with custom config.
config | Config. |
|
inline |
Share directly to Facebook Messenger.
config | Config. |
|
inline |
Share directly to Facebook Messenger with custom config.
config | Config. |
|
inline |
Share directly to Twitter.
config | Config. |
|
inline |
Share directly to Twitter with custom config.
config | Config. |
|
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.
|
inline |
Start recording a GIF
This will keep a buffer of 50 frames (default). The frames are overwritten until StopRecording
gets called.
|
inline |
Start customized GIF recording.
This will keep a buffer of 50 frames (default). The frames are overwritten until StopRecording
gets called.
config | Config to customize the recording. |
|
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.
|
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.
message | Brief summary of what you expected to happen and what happened |
Action Megacool.CompletedSharing |
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"); }
Action Megacool.DismissedSharing |
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"); }
|
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.
|
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.
|
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.
|
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.
Action Megacool.PossiblyCompletedSharing |
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.
|
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.
|
getset |
Set how frames should be captured.
The capture method.
|
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
.
|
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:
Or, to modify it later:
|
set |
The default share config. Will be merged with the config given to Share, if any.
|
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
|
staticget |
Gets the instance.
The instance.
|
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
.