Posted on

Sharing – Cross Platform Native Plugins: Essential Kit

Download

Documentation: https://assetstore.essentialkit.voxelbusters.com/

0:00 Welcome to Share CPNP2
0:20 Overview
1:29 Setup
1:45 Usage and Coding

In this lesson on how to use the Cross Platform Native Plugins 2, I will show you how to use the Sharing and Rate My App services. Adding Sharing to your app is vital to the growth of your audience. User to user sharing is the best way to get the word out and get your game noticed.

IG_Sharing.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VoxelBusters.EssentialKit;

public class IG_Sharing : MonoBehaviour
{
    [SerializeField] string textMessage;
    [SerializeField] string imageName;


    public void ShareText()
    {
        ShareSheet shareSheet = ShareSheet.CreateInstance();
        shareSheet.AddText(textMessage);
        shareSheet.SetCompletionCallback((result, error) =>
        {
            Debug.Log("Share Sheet was closed. Result code: " + result.ResultCode);
        });
        shareSheet.Show();
    }

    public void ShareTextWithScreenshot()
    {
        ShareSheet shareSheet = ShareSheet.CreateInstance();
        shareSheet.AddText(textMessage);
        shareSheet.AddScreenshot();
        shareSheet.SetCompletionCallback((result, error) =>
        {
            Debug.Log("Share Sheet was closed. Result code: " + result.ResultCode);
        });
        shareSheet.Show();
    }


    public void ShareImage()
    {
        Texture2D texture = Resources.Load<Texture2D>(imageName);

        ShareSheet shareSheet = ShareSheet.CreateInstance();
        shareSheet.AddImage(texture);
        shareSheet.SetCompletionCallback((result, error) =>
        {
            Debug.Log("Share Sheet was closed. Result code: " + result.ResultCode);
        });
        shareSheet.Show();
    }
}