Ejemplo n.º 1
0
    //****************** 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();
    }
Ejemplo n.º 2
0
    private void InitializeSharingDelegate()
    {
#if UNITY_IOS && !UNITY_EDITOR
        MegacoolDidCompleteShareDelegate didCompleteShareDelegate = new MegacoolDidCompleteShareDelegate(DidCompleteShare);
        MegacoolDidDismissShareDelegate  didDismissShareDelegate  = new MegacoolDidDismissShareDelegate(DidDismissShare);

        setMegacoolDidCompleteShareDelegate(Marshal.GetFunctionPointerForDelegate(didCompleteShareDelegate));
        setMegacoolDidDismissShareDelegate(Marshal.GetFunctionPointerForDelegate(didDismissShareDelegate));

        OnLinkClickedEventDelegate         onLinkClickedEventDelegate         = new OnLinkClickedEventDelegate(OnLinkClickedEvent);
        OnReceivedShareOpenedEventDelegate onReceivedShareOpenedEventDelegate = new OnReceivedShareOpenedEventDelegate(OnReceivedShareOpenedEvent);
        OnSentShareOpenedEventDelegate     onSentShareOpenedEventDelegate     = new OnSentShareOpenedEventDelegate(OnSentShareOpenedEvent);

        setOnLinkClickedEventDelegate(Marshal.GetFunctionPointerForDelegate(onLinkClickedEventDelegate));
        setOnReceivedShareOpenedEventDelegate(Marshal.GetFunctionPointerForDelegate(onReceivedShareOpenedEventDelegate));
        setOnSentShareOpenedEventDelegate(Marshal.GetFunctionPointerForDelegate(onSentShareOpenedEventDelegate));

        setOnRetrievedSharesDelegate(Marshal.GetFunctionPointerForDelegate(new OnRetrievedSharesDelegate(OnRetrievedShares)));
#endif
    }