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); } }); }