public static Permission TakePicture(CameraCallback callback, int maxSize = -1) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID object threadLock = new object(); lock ( threadLock ) { NCCameraCallbackAndroid nativeCallback = new NCCameraCallbackAndroid(threadLock); AJC.CallStatic("TakePicture", Context, nativeCallback); if (string.IsNullOrEmpty(nativeCallback.Path)) { System.Threading.Monitor.Wait(threadLock); } string path = nativeCallback.Path; if (string.IsNullOrEmpty(path)) { path = null; } if (callback != null) { callback(path); } } #elif !UNITY_EDITOR && UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath, maxSize); #else if (callback != null) { callback(null); } #endif } return(result); }
public static Permission RecordVideo(CameraCallback callback, Quality quality = Quality.Default, int maxDuration = 0, long maxSizeBytes = 0L) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID object threadLock = new object(); lock ( threadLock ) { NCCameraCallbackAndroid nativeCallback = new NCCameraCallbackAndroid(threadLock); AJC.CallStatic("RecordVideo", Context, nativeCallback, (int)quality, maxDuration, maxSizeBytes); if (string.IsNullOrEmpty(nativeCallback.Path)) { System.Threading.Monitor.Wait(threadLock); } string path = nativeCallback.Path; if (string.IsNullOrEmpty(path)) { path = null; } if (callback != null) { callback(path); } } #elif !UNITY_EDITOR && UNITY_IOS NCCameraCallbackiOS.Initialize(callback); _NativeCamera_RecordVideo((int)quality, maxDuration); #else if (callback != null) { callback(null); } #endif } return(result); }