public void ShareScreenshot(MegacoolRecordingConfig recordingConfig,
                                MegacoolShareConfig shareConfig)
    {
        IntPtr recordingPointer = IntPtr.Zero;

        if (recordingConfig != null)
        {
            recordingPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCLRecordingConfig)));
            MCLRecordingConfig nativeRecordingConfig = GetNativeRecordingConfig(recordingConfig);
            Marshal.StructureToPtr(nativeRecordingConfig, recordingPointer, false);
        }
        IntPtr sharePointer = IntPtr.Zero;

        if (shareConfig != null)
        {
            sharePointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCLShareConfig)));
            MCLShareConfig nativeShareConfig = GetNativeShareConfig(shareConfig);
            Marshal.StructureToPtr(nativeShareConfig, sharePointer, false);
        }

        mcl_share_screenshot(recordingPointer, sharePointer);

        if (recordingConfig != null)
        {
            Marshal.FreeHGlobal(recordingPointer);
        }
        if (shareConfig != null)
        {
            Marshal.FreeHGlobal(sharePointer);
        }
    }
    public void ShareToMail(MegacoolShareConfig config)
    {
        if (config == null)
        {
            mcl_present_share_to_mail(IntPtr.Zero);
            return;
        }
        MCLShareConfig nativeConfig = GetNativeShareConfig(config);
        IntPtr         pointer      = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MCLShareConfig)));

        Marshal.StructureToPtr(nativeConfig, pointer, false);
        mcl_present_share_to_mail(pointer);
        Marshal.FreeHGlobal(pointer);
    }
    private MCLShareConfig GetNativeShareConfig(MegacoolShareConfig config)
    {
        MCLShareConfig nativeConfig = new MCLShareConfig {
            strategy            = -1,
            popover_source_rect = new MCLRect {
                x      = -1,
                y      = -1,
                width  = -1,
                height = -1,
            },
            popover_permitted_arrow_directions = -1,
        };

        if (config._HasStrategy())
        {
            nativeConfig.strategy = (int)config.Strategy;
        }
        if (config._HasMessage())
        {
            nativeConfig.message = config.Message;
        }
        if (config._HasRecordingId())
        {
            nativeConfig.recordingId = config.RecordingId;
        }
        if (config.Url != null)
        {
            nativeConfig.url = config.Url.ToString();
        }
        if (config.FallbackImage != null)
        {
            nativeConfig.fallback_image = Application.streamingAssetsPath + "/" + config.FallbackImage;
        }
        if (config.Data != null)
        {
            nativeConfig.jsonData = Json.Serialize(config.Data);
        }
        if (config._HasModalLocation())
        {
            nativeConfig.popover_source_rect.x      = config.ModalLocation.x;
            nativeConfig.popover_source_rect.y      = config.ModalLocation.y;
            nativeConfig.popover_source_rect.width  = config.ModalLocation.width;
            nativeConfig.popover_source_rect.height = config.ModalLocation.height;
        }
        if (config._HasModalPermittedArrowDirections())
        {
            nativeConfig.popover_permitted_arrow_directions = (int)config.ModalPermittedArrowDirections;
        }
        return(nativeConfig);
    }