public static Permission RecordVideo(CameraCallback callback, Quality quality = Quality.Default, int maxDuration = 0, long maxSizeBytes = 0L, PreferredCamera preferredCamera = PreferredCamera.Default) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if UNITY_EDITOR string pickedFile = UnityEditor.EditorUtility.OpenFilePanelWithFilters("Select video", "", new string[] { "Video files", "mp4,mov,wav,avi", "All files", "*" }); if (callback != null) { callback(pickedFile != "" ? pickedFile : null); } #elif UNITY_ANDROID AJC.CallStatic("RecordVideo", Context, new NCCameraCallbackAndroid(callback), (int)preferredCamera, (int)quality, maxDuration, maxSizeBytes); #elif UNITY_IOS NCCameraCallbackiOS.Initialize(callback); _NativeCamera_RecordVideo((int)quality, maxDuration, (int)preferredCamera); #else if (callback != null) { callback(null); } #endif } return(result); }
public static Permission TakePicture(CameraCallback callback, int maxSize = -1, bool saveAsJPEG = true, PreferredCamera preferredCamera = PreferredCamera.Default) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if UNITY_EDITOR string pickedFile = UnityEditor.EditorUtility.OpenFilePanelWithFilters("Select image", "", new string[] { "Image files", "png,jpg,jpeg", "All files", "*" }); if (callback != null) { callback(pickedFile != "" ? pickedFile : null); } #elif UNITY_ANDROID AJC.CallStatic("TakePicture", Context, new NCCameraCallbackAndroid(callback), (int)preferredCamera); #elif UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath + (saveAsJPEG ? ".jpeg" : ".png"), maxSize, (int)preferredCamera); #else if (callback != null) { callback(null); } #endif } return(result); }
public static Permission TakePicture(CameraCallback callback, int maxSize = -1) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID AJC.CallStatic("TakePicture", Context, new NCCameraCallbackAndroid(callback)); #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 TakePicture(CameraCallback callback, int maxSize = -1, bool saveAsJPEG = true, PreferredCamera preferredCamera = PreferredCamera.Default) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID AJC.CallStatic("TakePicture", Context, new NCCameraCallbackAndroid(callback), (int)preferredCamera); #elif !UNITY_EDITOR && UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath + (saveAsJPEG ? ".jpeg" : ".png"), maxSize, (int)preferredCamera); #else if (callback != null) { callback(null); } #endif } return(result); }
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); }
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 AJC.CallStatic("RecordVideo", Context, new NCCameraCallbackAndroid(callback), (int)quality, maxDuration, maxSizeBytes); #elif !UNITY_EDITOR && UNITY_IOS NCCameraCallbackiOS.Initialize(callback); _NativeCamera_RecordVideo((int)quality, maxDuration); #else if (callback != null) { callback(null); } #endif } return(result); }