public static void OpenGallery(System.Action <Texture2D, ExifOrientation> callback, bool rotateImportedImage, Tastybits.NativeGallery.ImagePickerType iOSImagePickerType) { if (NativeGalleryController.Verbose) { Debug.Log("Opening Image Picker"); } _callback = callback; #if UNITY_IPHONE && !UNITY_EDITOR if (NativeGalleryController.Verbose) { Debug.Log("Opening Image Picker - iOS"); } UIImagePicker.OpenPhotoAlbum((Texture2D texture, bool ok, string errMsg) => { _callback(texture, UIImagePicker.GetLastImportedOrientation()); }, rotateImportedImage, iOSImagePickerType); #elif UNITY_ANDROID && !UNITY_EDITOR if (NativeGalleryController.Verbose) { Debug.Log("Opening Image Picker - Android"); } AndroidGallery.OpenGallery((Texture2D tex) => { _callback(tex, AndroidGallery.GetLastImportedOrientation()); }, rotateImportedImage); #elif UNITY_EDITOR if (NativeGalleryController.Verbose) { Debug.Log("Opening Image Picker - Editor"); } NativeGalleryController.OpenEditorGallery(callback); #else Debug.LogError("OpenGallery: Function not implemented for platform " + Application.platform); #endif }
public static void OpenPhotoAlbum(System.Action <Texture2D, bool, string> callback) { UIImagePicker.Open(ImagePickerType.UIImagePickerControllerSourceTypeSavedPhotosAlbum, (bool succeeded, bool cancelled, string path) => { Debug.Log("Native Camera Saved image at path : " + path); bool ok = succeeded; var www = new WWW(path); if (ok && !cancelled) { WWWUtil.Wait(www, (WWW w, bool www_ok) => { string msg = (www_ok ? "" : "error loading file"); if (www_ok && w.texture == null) { www_ok = false; msg = "texture is null"; } callback(w.texture, www_ok, msg); }); } else { string msg = cancelled ? "cancelled" : ""; callback(null, false, msg); } Texture2D tex; }); }
public static void OpenPhotoAlbum(System.Action <Texture2D, bool, string> callback, bool rotateImageOnImport, ImagePickerType galleryType = ImagePickerType.UIImagePickerControllerSourceTypeSavedPhotosAlbum) { UIImagePicker.Open(galleryType, rotateImageOnImport, (bool succeeded, bool cancelled, string path) => { Debug.Log("Native Camera Saved image at path : " + path); bool ok = succeeded; var www = new WWW(path); if (ok && !cancelled) { Tastybits.NativeGallery.NativeGalleryController.LastPickedImagePath = path; WWWUtil.Wait(www, (WWW w, bool www_ok) => { string msg = (www_ok ? "" : "error loading file"); if (www_ok && w.texture == null) { www_ok = false; msg = "texture is null"; } callback(w.texture, www_ok, msg); }); } else { Tastybits.NativeGallery.NativeGalleryController.LastPickedImagePath = ""; string msg = cancelled ? "cancelled" : ""; callback(null, false, msg); } }); }
public static void OpenGallery(System.Action <Texture2D> callback) { _callback = callback; #if UNITY_IPHONE && !UNITY_EDITOR UIImagePicker.OpenPhotoAlbum((Texture2D texture, bool ok, string errMsg) => { _callback(texture); }); #elif UNITY_ANDROID && !UNITY_EDITOR AndroidGallery.OpenGallery((Texture2D tex) => { _callback(tex); }); #elif UNITY_EDITOR NativeGalleryController.OpenEditorGallery(callback); #else Debug.LogError("OpenGallery: Function not implemented for platform " + Application.platform); #endif }