[go: up one dir, main page]

Skip to content

NatShare is a native sharing API for Unity Engine.

License

Notifications You must be signed in to change notification settings

handcircus/NatShare-API

 
 

Repository files navigation

NatShare API

NatShare is a lightweight, easy-to-use native sharing API for Unity Engine. NatShare supports images (using a Texture2D) and media files (using a string path). Currently, you can save media to the camera roll, open the native sharing UI, and retrieve a thumbnail for a video:

Native Sharing

To share an image, you can use the Share function:

Texture2D image = ...;
NatShare.Share(image);

The Share function also has an overload for sharing plain text or a media file:

string videoPath = "file://some/path/to/a/media/file.ext";
NatShare.Share(videoPath);
string message = "Happy Birthday!";
NatShare.Share(message);

All sharing functions take a callback parameter. This callback can be used to know when the user has finished the sharing activity:

string videoPath = ...;
NatShare.ShareMedia(videoPath, callback: OnShare);

void OnShare () {
    Debug.Log("User shared recording!");
}

Saving to the Camera Roll

You can save images or media files to the camera roll:

// Save a texture to the camera roll
Texture2D image = ...;
NatShare.SaveToCameraRoll(image);
// Now save a media file to the camera roll
string gifPath = ...;
NatShare.SaveToCameraRoll(gifPath);

Retrieving a Video Thumbnail

NatShare also supports generating thumbnails for videos:

string videoPath = ...;
var thumbnail = NatShare.GetThumbnail(videoPath);
// Do stuff with thumbnail...

You can also request the thumbnail at a specific time in the video:

string videoPath = ...;
// Request the thumbnail at 5 seconds
var thumbnail = NatShare.GetThumbnail(videoPath, 5f);

Requirements

  • On Android, NatShare requires API Level 16 and up
  • On iOS, NatShare requires iOS 7 and up

Quick Tips

Thank you very much!

About

NatShare is a native sharing API for Unity Engine.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 36.7%
  • C# 27.4%
  • C 17.4%
  • Java 15.1%
  • JavaScript 3.2%
  • Shell 0.2%