NatShare
Search…
⌃K

Getting Started

Up and Running in No Time

Importing NatShare

To begin, import the API with the Unity Package Manager by adding the following items to your Packages/manifest.json file:
{
"scopedRegistries": [
{
"name": "NatML",
"url": "https://registry.npmjs.com",
"scopes": ["ai.natml"]
}
],
"dependencies": {
"ai.natml.natshare": "1.3.0",
...
}
}

Specifying your Access Key

In order to use NatShare, you need a NatML access key. Retrieve your access key from NatML Hub:
https://hub.natml.ai/profile
Retrieve your access key on NatML Hub.
Once you have your access key, add it in Project Settings > NatML:
Specifying your NatML access key in Project Settings.

Sharing a Screenshot

With NatShare imported, let's write a quick script to share a screenshot:
ShareScreenshot.cs
using UnityEngine;
using NatML.Sharing;
public class ShareScreenshot : MonoBehaviour {
void Start () {
// Capture a screenshot
var screenshot = ScreenCapture.CaptureScreenshotAsTexture();
// Create a share payload
using var payload = new SharePayload();
// Add the image
payload.AddImage(screenshot);
// Share!
payload.Share();
}
}
Add this component to any game object in your scene; build onto an iOS or Android device, and run. You should get a native popup asking the user to share the item!
Make sure to look through the minimum requirements before delving into the API.