public EditorIosImagePickerResult( bool didCancel, string mediaType, EditorIosImagePickerImageResult image, EditorIosImagePickerMovieResult movie, string mediaMetadataJson) { this.DidCancel = didCancel; this.MediaType = mediaType; this.Image = image; this.Movie = movie; this.MediaMetadataJson = mediaMetadataJson; }
public void Present(IosImagePickerPresentArgs presentArgs, Action <IIosImagePickerResult> resultCallback) { var filters = new List <string>(); if (Array.IndexOf(this.MediaTypes, this.MediaTypeImage) != -1) { filters.Add("Image files"); filters.Add(ImageFilter); } if (Array.IndexOf(this.MediaTypes, this.MediaTypeMovie) != -1) { filters.Add("Movie files"); filters.Add(MovieFilter); } var result = default(EditorIosImagePickerResult); var filePath = EditorUtility.OpenFilePanelWithFilters("Open file", "", filters.ToArray()); if (!string.IsNullOrEmpty(filePath)) { var mediaType = default(string); var extension = Path.GetExtension(filePath).TrimStart('.').ToLower(); if (ImageFilter.Contains(extension)) { mediaType = this.MediaTypeImage; } else if (MovieFilter.Contains(extension)) { mediaType = this.MediaTypeMovie; } var image = default(EditorIosImagePickerImageResult); var movie = default(EditorIosImagePickerMovieResult); if (mediaType == this.MediaTypeImage) { image = new EditorIosImagePickerImageResult( Rect.zero, filePath, null, null, null, filePath, null); } else if (mediaType == this.MediaTypeMovie) { movie = new EditorIosImagePickerMovieResult( filePath, null); } result = new EditorIosImagePickerResult( false, mediaType, image, movie, null); } else { result = new EditorIosImagePickerResult( true, null, null, null, null); } lock (this._syncLock) { this._scheduledCallbacks.Add(() => resultCallback.Invoke(result)); } }