Пример #1
0
        void INatShare.GetThumbnail(string videoPath, Action <Texture2D> callback, float time)
        {
            IntPtr[] thumbnailData = new IntPtr[3]; int unused = 0;
            var      thumbnailHandle = GCHandle.Alloc(thumbnailData, GCHandleType.Pinned);

            NatShareBridge.GetThumbnail(videoPath, time, ref thumbnailData[0], ref unused, ref unused);
            var callbackObject = new GameObject("NatShareWebGL Delegate").AddComponent <ThumbnailDelegate>();

            callbackObject.StartCoroutine(GetThumbnail(thumbnailHandle, callback, callbackObject));
        }
Пример #2
0
 bool INatShare.SaveToCameraRoll(string videoPath, bool isvideo)
 {
     if (isvideo)
     {
         return(NatShareBridge.SaveToCameraRoll(videoPath, true));
     }
     else
     {
         Debug.LogError("Natshare does not allow sharing images with path on iOS!");
         return(false);
     }
 }
Пример #3
0
        bool INatShare.Share(string media, ShareCallback callback)
        {
            this.callback = callback;
            Uri uri;

            if (Uri.TryCreate(media, UriKind.Absolute, out uri))
            {
                return(NatShareBridge.ShareMedia(media));
            }
            else
            {
                return(NatShareBridge.ShareText(media));
            }
        }
Пример #4
0
        void INatShare.GetThumbnail(string videoPath, Action <Texture2D> callback, float time)
        {
            IntPtr pixelBuffer = IntPtr.Zero; int width = 0, height = 0;

            if (!NatShareBridge.GetThumbnail(videoPath, time, ref pixelBuffer, ref width, ref height))
            {
                Debug.LogError("NatShare Error: Failed to get thumbnail for video at path: " + videoPath);
                callback(null);
            }
            var thumbnail = new Texture2D(width, height, TextureFormat.BGRA32, false);

            thumbnail.LoadRawTextureData(pixelBuffer, width * height * 4);
            thumbnail.Apply();
            NatShareBridge.FreeThumbnail(pixelBuffer);
            callback(thumbnail);
        }
Пример #5
0
        private IEnumerator GetThumbnail(GCHandle thumbnailHandle, Action <Texture2D> callback, ThumbnailDelegate callbackObject)
        {
            yield return(new WaitUntil(() => Marshal.ReadIntPtr(thumbnailHandle.AddrOfPinnedObject()) != IntPtr.Zero));

            MonoBehaviour.Destroy(callbackObject); // We don't need this anymore
            var pixelBuffer = Marshal.ReadIntPtr(thumbnailHandle.AddrOfPinnedObject());
            var width       = Marshal.ReadInt32(new IntPtr(thumbnailHandle.AddrOfPinnedObject().ToInt32() + sizeof(int)));
            var height      = Marshal.ReadInt32(new IntPtr(thumbnailHandle.AddrOfPinnedObject().ToInt32() + 2 * sizeof(int)));
            var thumbnail   = new Texture2D(width, height, TextureFormat.RGBA32, false);

            thumbnail.LoadRawTextureData(pixelBuffer, width * height * 4);
            thumbnail.Apply();
            NatShareBridge.FreeThumbnail(thumbnailHandle.AddrOfPinnedObject());
            thumbnailHandle.Free();
            callback(thumbnail);
        }
Пример #6
0
 void INatShare.EnableCallbacks(string gameObjectName, string successMethodName, string failureMethodName)
 {
     NatShareBridge.EnableCallbacks(gameObjectName, successMethodName, failureMethodName);
 }
Пример #7
0
 bool INatShare.SaveToCameraRoll(string path, string album, bool copy)
 {
     return(NatShareBridge.SaveToCameraRoll(path, album, copy));
 }
Пример #8
0
 bool INatShare.SaveToCameraRoll(byte[] pngData)
 {
     return(NatShareBridge.SaveToCameraRoll(pngData, pngData.Length));
 }
Пример #9
0
 bool INatShare.Share(string path, string message)
 {
     return(NatShareBridge.Share(path, message));
 }
Пример #10
0
 bool INatShare.Share(byte[] pngData, string message)
 {
     return(NatShareBridge.Share(pngData, pngData.Length, message));
 }
Пример #11
0
 bool INatShare.SaveToCameraRoll(string videoPath)
 {
     return(NatShareBridge.SaveToCameraRoll(videoPath));
 }
Пример #12
0
 bool INatShare.Share(string text)
 {
     return(NatShareBridge.Share(text));
 }
Пример #13
0
 bool INatShare.SaveToCameraRoll(byte[] pngData, string album)
 {
     return(NatShareBridge.SaveToCameraRoll(pngData, pngData.Length, album));
 }
Пример #14
0
 bool INatShare.ShareMedia(string path, string message, ShareCallback callback)
 {
     this.callback = callback;
     return(NatShareBridge.Share(path, message));
 }
Пример #15
0
 bool INatShare.ShareImage(byte[] pngData, string message, ShareCallback callback)
 {
     this.callback = callback;
     return(NatShareBridge.Share(pngData, pngData.Length, message));
 }
Пример #16
0
 bool INatShare.ShareText(string text, ShareCallback callback)
 {
     this.callback = callback;
     return(NatShareBridge.Share(text));
 }
Пример #17
0
 public NatShareiOS()
 {
     NatShareBridge.RegisterCallbacks(OnShare);
 }