//****************** API Implementation  ******************//
    public void Start(MegacoolInternal.EventHandler eventHandler)
    {
        this.eventHandler = eventHandler;

        shareCompletedDelegate      = new MegacoolDidCompleteShareDelegate(DidCompleteShare);
        shareDismissedDelegate      = new MegacoolDidDismissShareDelegate(DidDismissShare);
        linkClickedDelegate         = new OnLinkClickedEventDelegate(OnLinkClickedEvent);
        receivedShareOpenedDelegate = new OnReceivedShareOpenedEventDelegate(OnReceivedShareOpenedEvent);
        sentShareOpenedDelegate     = new OnSentShareOpenedEventDelegate(OnSentShareOpenedEvent);
        sharesRetrievedDelegate     = new OnRetrievedSharesDelegate(OnRetrievedShares);

        MCLConfig config = new MCLConfig {
            wrapper                       = "Unity",
            wrapper_version               = Application.unityVersion,
            base_url                      = MegacoolConfiguration.Instance.CustomBaseUrl(),
            link_clicked_handler          = Marshal.GetFunctionPointerForDelegate(linkClickedDelegate),
            received_share_opened_handler = Marshal.GetFunctionPointerForDelegate(receivedShareOpenedDelegate),
            sent_share_opened_handler     = Marshal.GetFunctionPointerForDelegate(sentShareOpenedDelegate),
            share_completed_handler       = Marshal.GetFunctionPointerForDelegate(shareCompletedDelegate),
            share_dismissed_handler       = Marshal.GetFunctionPointerForDelegate(shareDismissedDelegate),
        };

        IntPtr configPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCLConfig)));

        Marshal.StructureToPtr(config, configPointer, false);
        mcl_start_with_app_config(MegacoolConfiguration.Instance.appConfigIos, configPointer);
        Marshal.FreeHGlobal(configPointer);

        mcl_set_on_retrieved_shares_delegate(Marshal.GetFunctionPointerForDelegate(sharesRetrievedDelegate));
        mcl_manual_application_did_become_active();
    }
Example #2
0
    /// <summary>
    /// Initialize the SDK.
    /// </summary>
    /// <remarks>
    /// To listen for events for the SDK, make sure you register the delegates for
    /// <c>Megacool.Instance.LinkClicked</c>/<c>Megacool.Instance.OnReceivedShareOpened</c> and
    /// similar *before* calling this.
    /// </remarks>
    public void Start()
    {
        // Create a main thread action for every asynchronous callback
        MegacoolInternal.EventHandler eventHandler = new MegacoolInternal.EventHandler(this);

        if (hasStarted)
        {
            // Allowing multiple initializations would make it hard to maintain both thread-safety and performance
            // of the underlying capture code, and doesn't have any good use case for allowing it, thus ignoring.
            UnityEngine.Debug.Log("Megacool: Skipping duplicate init");
            return;
        }
        hasStarted = true;

        // Set debugging first so that it can be enabled before initializing the native SDK
        Debug = MegacoolConfiguration.Instance.debugMode;

        _platformAgent.Start(eventHandler);

        SetupDefaultConfiguration();

        _platformAgent.InitializeCapture(ScaleFactor, _TextureReadCompleteCallback);
        _IssuePluginEvent(MCRS);
        _platformAgent.SignalRenderTexture(renderTexture);
    }
    //****************** API Implementation  ******************//
    public void Start(MegacoolInternal.EventHandler eventHandler)
    {
        AndroidJavaObject jConfig = new AndroidJavaObject("co.megacool.megacool.MegacoolConfig");

        jConfig.Call <AndroidJavaObject>("wrapper", "Unity", Application.unityVersion);
        jConfig.Call <AndroidJavaObject>("baseEventListener", new UnityEventsListener(eventHandler));
        AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
        string           baseUrl  = MegacoolConfiguration.Instance.CustomBaseUrl();

        if (baseUrl != null)
        {
            AndroidJavaObject jBaseUrl = uriClass.CallStatic <AndroidJavaObject>("parse", baseUrl);
            jConfig.Call <AndroidJavaObject>("baseUrl", jBaseUrl);
        }

        megacool = Android.CallStatic <AndroidJavaObject>("start", CurrentActivity,
                                                          MegacoolConfiguration.Instance.appConfigAndroid, jConfig);
    }
 public UnityEventsListener(MegacoolInternal.EventHandler eventHandler) : base("co.megacool.megacool.BaseEventListener")
 {
     this.eventHandler = eventHandler;
 }
 //****************** API Implementation  ******************//
 public void Start(MegacoolInternal.EventHandler eventHandler)
 {
     recordingManager = new MegacoolEditorRecordingManager();
 }
 public void Start(MegacoolInternal.EventHandler eventHandler)
 {
     Debug.LogWarning("Megacool: Unsupported platform, all functionality will be a no-op." +
                      "This version of the SDK is only supported on iOS and Android.");
 }