Megacool Unity
The Unity interface to the Megacool SDK
|
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< MegacoolLinkClickedEvent > | LinkClicked |
Callback when a link click was detected. Use this for navigation within the app. More... | |
Action< MegacoolReceivedShareOpenedEvent > | ReceivedShareOpened |
Callback when the user clicks on someone else's share. More... | |
Action< MegacoolSentShareOpenedEvent > | SentShareOpened |
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... | |
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 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.
-1
if the recording couldn't be found. recordingId | The recording to fetch the score for. Fetches the default if null . |
|
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 |
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.
|
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 |
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.
recordingConfig | The recording config, or null . Most properties don't apply to screenshots, but the last frame overlay does. |
shareConfig | The share config, or null . |
|
inline |
Share directly to email with custom config.
|
inline |
Share directly to email with custom config.
config | Config. |
|
inline |
Share directly to SMS.
|
inline |
Share directly to SMS with custom config.
config | Config. |
|
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.
|
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+.
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"); }
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"); }
Action<MegacoolLinkClickedEvent> Megacool.LinkClicked |
Callback when a link click was detected. Use this for navigation within the app.
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.
Action<MegacoolReceivedShareOpenedEvent> Megacool.ReceivedShareOpened |
Callback when the user clicks on someone else's share.
|
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.
Action<MegacoolSentShareOpenedEvent> Megacool.SentShareOpened |
Callback when a share sent by the user was clicked on by someone else.
|
getset |
Set how frames should be captured.
|
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
.