From ce6dd85cb4b719edf2208ab17f700078371e5374 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Fri, 24 Mar 2023 23:27:08 +0300 Subject: [PATCH] Bugfix for LoadImageAtPathAsync and GetVideoThumbnailAsync --- Plugins/NativeCamera/NativeCamera.cs | 12 ++++++++---- Plugins/NativeCamera/README.txt | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Plugins/NativeCamera/NativeCamera.cs b/Plugins/NativeCamera/NativeCamera.cs index b84747b..0d69e8b 100644 --- a/Plugins/NativeCamera/NativeCamera.cs +++ b/Plugins/NativeCamera/NativeCamera.cs @@ -361,9 +361,11 @@ public static async Task LoadImageAtPathAsync( string imagePath, int maxSize = SystemInfo.maxTextureSize; #if !UNITY_EDITOR && UNITY_ANDROID - string loadPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic( "LoadImageAtPath", Context, imagePath, TemporaryImagePath, maxSize ) ); + string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread + string loadPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic( "LoadImageAtPath", Context, imagePath, temporaryImagePath, maxSize ) ); #elif !UNITY_EDITOR && UNITY_IOS - string loadPath = await Task.Run( () => _NativeCamera_LoadImageAtPath( imagePath, TemporaryImagePath, maxSize ) ); + string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread + string loadPath = await Task.Run( () => _NativeCamera_LoadImageAtPath( imagePath, temporaryImagePath, maxSize ) ); #else string loadPath = imagePath; #endif @@ -496,9 +498,11 @@ public static async Task GetVideoThumbnailAsync( string videoPath, in maxSize = SystemInfo.maxTextureSize; #if !UNITY_EDITOR && UNITY_ANDROID - string thumbnailPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic( "GetVideoThumbnail", Context, videoPath, TemporaryImagePath + ".png", false, maxSize, captureTimeInSeconds ) ); + string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread + string thumbnailPath = await TryCallNativeAndroidFunctionOnSeparateThread( () => AJC.CallStatic( "GetVideoThumbnail", Context, videoPath, temporaryImagePath + ".png", false, maxSize, captureTimeInSeconds ) ); #elif !UNITY_EDITOR && UNITY_IOS - string thumbnailPath = await Task.Run( () => _NativeCamera_GetVideoThumbnail( videoPath, TemporaryImagePath + ".png", maxSize, captureTimeInSeconds ) ); + string temporaryImagePath = TemporaryImagePath; // Must be accessed from main thread + string thumbnailPath = await Task.Run( () => _NativeCamera_GetVideoThumbnail( videoPath, temporaryImagePath + ".png", maxSize, captureTimeInSeconds ) ); #else string thumbnailPath = null; #endif diff --git a/Plugins/NativeCamera/README.txt b/Plugins/NativeCamera/README.txt index 89be8ba..8884b69 100644 --- a/Plugins/NativeCamera/README.txt +++ b/Plugins/NativeCamera/README.txt @@ -1,4 +1,4 @@ -= Native Camera for Android & iOS (v1.3.7) = += Native Camera for Android & iOS (v1.3.8) = Online documentation & example code available at: https://github.com/yasirkula/UnityNativeCamera E-mail: yasirkula@gmail.com diff --git a/package.json b/package.json index 65c917f..6c74184 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.nativecamera", "displayName": "Native Camera", - "version": "1.3.7", + "version": "1.3.8", "documentationUrl": "https://github.com/yasirkula/UnityNativeCamera", "changelogUrl": "https://github.com/yasirkula/UnityNativeCamera/releases", "licensesUrl": "https://github.com/yasirkula/UnityNativeCamera/blob/master/LICENSE.txt",