/// <summary> /// Saves images to the device gallery. /// </summary> /// <param name="image">Image that needs to be saved</param> /// <param name="name">Image name. If image with the same name already exists, it will be replaced</param> /// <param name="appDirectory">app directory name</param> /// <param name="format">save format</param> /// <param name="callback">Operation callback.</param> public static void SaveImageToGallery(Texture2D image, string name, string appDirectory, AN_GalleryFormat format, Action <AN_GallerySaveResult> callback) { AN_GalleryInternal.SaveImageToGallery(image, name, appDirectory, format, callback); }
public static void SaveImageToGallery(Texture2D image, string name, string appDirectory, AN_GalleryFormat format, Action <AN_GallerySaveResult> callback) { string base64 = image.ToBase64String(); int saveFormat = (int)format; if (Application.isEditor) { SA_Coroutine.WaitForSeconds(1, () => { var error = new SA_Error(100, "Gallery does not avaliable on current device"); callback.Invoke(new AN_GallerySaveResult(error)); }); return; } AN_Java.Bridge.CallStaticWithCallback(ANDROID_CLASS, "SaveImageToGallery", callback, base64, appDirectory, name, saveFormat); }