public override void Update() { if (CheckImageSavedDoneStatus()) { if (streamFileSavedCallback != null) { streamFileSavedCallback(CheckImageSavedSucceededStatus()); streamFileSavedCallback = null; } } if (CheckImageLoadStatus()) { if (streamFileLoadedCallback != null) { bool succeeded; byte[] data = null; unsafe { IntPtr dataPtr = IntPtr.Zero; int dataSize; succeeded = CheckImageLoadSucceededStatus(ref dataPtr, &dataSize); if (succeeded) { data = new byte[dataSize]; Marshal.Copy(dataPtr, data, 0, data.Length); Marshal.FreeHGlobal(dataPtr); } } streamFileLoadedCallback(succeeded ? new MemoryStream(data) : null, succeeded); streamFileLoadedCallback = null; } } }
public override void SaveFileDialog(Stream stream, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (streamSavedCallback == null) return; var data = new byte[stream.Length]; stream.Position = 0; stream.Read(data, 0, data.Length); SaveFileDialog(data, folderLocation, fileTypes, streamSavedCallback); }
public override void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (streamSavedCallback == null) return; // open native dlg var file = new OPENFILENAME(); file.lStructSize = (uint)Marshal.SizeOf(typeof(OPENFILENAME)); file.hwndOwner = IntPtr.Zero; file.lpstrDefExt = IntPtr.Zero; file.lpstrFile = Marshal.AllocHGlobal((int)MAX_PATH); unsafe {((byte*)file.lpstrFile.ToPointer())[0] = 0;} file.nMaxFile = MAX_PATH; file.lpstrFilter = generateFilterValue(fileTypes); file.nFilterIndex = 0; file.lpstrInitialDir = Marshal.StringToHGlobalUni(Application.dataPath); file.lpstrTitle = Marshal.StringToHGlobalUni("Save file"); file.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR; GetSaveFileName(ref file); // get native dlg result string filename = null; if (file.lpstrFile != IntPtr.Zero) { filename = Marshal.PtrToStringUni(file.lpstrFile); Debug.Log("Saving file: " + filename); } Marshal.FreeHGlobal(file.lpstrFile); Marshal.FreeHGlobal(file.lpstrInitialDir); Marshal.FreeHGlobal(file.lpstrTitle); Marshal.FreeHGlobal(file.lpstrFilter); // save file if (!string.IsNullOrEmpty(filename)) { using (var stream = new FileStream(filename, FileMode.Create, FileAccess.Write)) { stream.Write(data, 0, data.Length); } if (streamSavedCallback != null) streamSavedCallback(true); } else { if (streamSavedCallback != null) streamSavedCallback(false); } }
public override void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { string fileName = EditorUtility.SaveFilePanel("Save file", "", "FileName", generateFilterValue(fileTypes)); if (!string.IsNullOrEmpty(fileName)) { using (var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { stream.Write(data, 0, data.Length); } if (streamSavedCallback != null) streamSavedCallback(true); } else { if (streamSavedCallback != null) streamSavedCallback(false); } }
public override void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { if (folderLocation == FolderLocations.Pictures) { streamFileSavedCallback = steamSavedCallback; native.CallStatic("SaveImage", data, Path.GetFileNameWithoutExtension(fileName), ""); } else if (folderLocation != FolderLocations.Storage) { Debug.LogError("Save file in folder location: " + folderLocation + " is not supported."); if (steamSavedCallback != null) steamSavedCallback(false); } else { base.SaveFile(fileName, data, folderLocation, steamSavedCallback); } }
public virtual void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { try { using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { file.Write(data, 0, data.Length); } } catch (Exception e) { Debug.LogError(e.Message); if(steamSavedCallback != null) steamSavedCallback(false); return; } if(steamSavedCallback != null) steamSavedCallback(true); }
public override void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { if (folderLocation == FolderLocations.Pictures) { using (var file = new FileStream("/accounts/1000/shared/photos/"+fileName, FileMode.Create, FileAccess.Write)) { file.Write(data, 0, data.Length); } if(steamSavedCallback != null) steamSavedCallback(true); } else if (folderLocation != FolderLocations.Storage) { Debug.LogError("Save file in folder location: " + folderLocation + " is not supported."); if (steamSavedCallback != null) steamSavedCallback(false); } else { base.SaveFile(fileName, data, folderLocation, steamSavedCallback); } }
public override void Update() { if (native.CallStatic<bool>("CheckSaveImageDone")) { if (streamFileSavedCallback != null) { streamFileSavedCallback(native.CallStatic<bool>("CheckSaveImageSucceeded")); streamFileSavedCallback = null; } } if (native.CallStatic<bool>("CheckLoadImageDone")) { if (streamFileLoadedCallback != null) { bool succeeded = native.CallStatic<bool>("CheckLoadImageSucceeded"); if (succeeded) streamFileLoadedCallback(new MemoryStream(native.CallStatic<byte[]>("GetLoadedImageData")), succeeded); else streamFileLoadedCallback(null, succeeded); streamFileLoadedCallback = null; } } }
public void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { #if UNITY_METRO && !UNITY_WP_8_1 saveFileDialogAsync(data, folderLocation, fileTypes, streamSavedCallback); #else Debug.LogError("SaveFileDialog not supported on WP8!"); if (streamSavedCallback != null) streamSavedCallback(false); #endif }
private async void saveFileAsync(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { try { #if WINDOWS_PHONE if (folderLocation == FolderLocations.Pictures) { using (var m = new MediaLibrary()) using (var image = m.SavePicture(fileName, data)) { if (streamSavedCallback != null) streamSavedCallback(image != null); } return; } #endif fileName = fileName.Replace('/', '\\'); using (var stream = await saveStream(fileName, folderLocation)) { stream.Write(data, 0, data.Length); } } catch (Exception e) { Debug.LogError(e.Message); if (streamSavedCallback != null) streamSavedCallback(false); return; } if (streamSavedCallback != null) streamSavedCallback(true); }
public override void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { if (folderLocation == FolderLocations.Pictures) { streamFileSavedCallback = steamSavedCallback; unsafe { fixed (byte* dataPtr = data) { SaveImageStream(dataPtr, data.Length); } } } else if (folderLocation != FolderLocations.Storage) { Debug.LogError("Save file in folder location: " + folderLocation + " is not supported."); if (steamSavedCallback != null) steamSavedCallback(false); } else { base.SaveFile(fileName, data, folderLocation, steamSavedCallback); } }
public void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { if (steamSavedCallback != null) steamSavedCallback(false); }
/// <summary> /// Use to save a file. /// </summary> /// <param name="fileName"></param> /// <param name="data">Data to save.</param> /// <param name="folderLocation">Folder location to save file.</param> /// <param name="streamSavedCallback">The callback that fires when done.</param> public static void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { if (savingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.SaveFile); que.streamSavedCallback = streamSavedCallback; que.FileName = fileName; que.Data = data; que.FolderLocation = folderLocation; ques.Add(que); return; } savingStream = true; StreamManager.streamSavedCallback = streamSavedCallback; plugin.SaveFile(getCorrectUnityPath(fileName, folderLocation), data, folderLocation, async_streamSavedCallback); }
public override void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { if (folderLocation == FolderLocations.Pictures) { streamFileSavedCallback = steamSavedCallback; native.CallStatic("SaveImage", data, Path.GetFileNameWithoutExtension(fileName), ""); } else if (folderLocation != FolderLocations.Storage) { Debug.LogError("Save file in folder location: " + folderLocation + " is not supported."); if (steamSavedCallback != null) { steamSavedCallback(false); } } else { base.SaveFile(fileName, data, folderLocation, steamSavedCallback); } }
public override void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { string fileName = EditorUtility.SaveFilePanel("Save file", "", "FileName", generateFilterValue(fileTypes)); if (!string.IsNullOrEmpty(fileName)) { using (var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { stream.Write(data, 0, data.Length); } if (streamSavedCallback != null) { streamSavedCallback(true); } } else { if (streamSavedCallback != null) { streamSavedCallback(false); } } }
public override void SaveFileDialog(Stream stream, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (streamSavedCallback == null) { return; } var data = new byte[stream.Length]; stream.Position = 0; stream.Read(data, 0, data.Length); SaveFileDialog(data, folderLocation, fileTypes, streamSavedCallback); }
private async void saveFileDialogAsync(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() { var picker = new FileSavePicker(); if (fileTypes != null && fileTypes.Length != 0) { picker.FileTypeChoices.Add(new KeyValuePair <string, IList <string> >("Supported File Types", fileTypes)); } picker.SuggestedStartLocation = getFolderType(folderLocation); var file = await picker.PickSaveFileAsync(); if (file != null) { using (var fileStream = await file.OpenStreamForWriteAsync()) { fileStream.Write(data, 0, data.Length); if (streamSavedCallback != null) { streamSavedCallback(true); } } } else { if (streamSavedCallback != null) { streamSavedCallback(false); } } }); }
/// <summary> /// Use to save a file. /// </summary> /// <param name="fileName"></param> /// <param name="data">Data to save.</param> /// <param name="folderLocation">Folder location to save file.</param> /// <param name="streamSavedCallback">The callback that fires when done.</param> public static void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { if (savingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.SaveFile); que.streamSavedCallback = streamSavedCallback; que.FileName = fileName; que.Data = data; que.FolderLocation = folderLocation; ques.Add(que); return; } savingStream = true; StreamManager.streamSavedCallback = streamSavedCallback; plugin.SaveFile(getCorrectUnityPath(fileName, folderLocation), data, folderLocation, async_streamSavedCallback); }
/// <summary> /// Use to save a ScreenShot of you game to the pictures folder. /// </summary> /// <param name="streamSavedCallback"></param> public static void SaveScreenShotToPictures(StreamSavedCallbackMethod streamSavedCallback) { if (savingStream) { Debug.LogError("You must wait for the last saved file to finish!"); if (streamSavedCallback != null) streamSavedCallback(false); return; } StreamManager.streamSavedCallback = streamSavedCallback; ReignServices.CaptureScreenShot(captureScreenShotCallback); }
/// <summary> /// Use to have the user pic where a file should be saved. /// NOTE: Does not work on all platforms. /// </summary> /// <param name="data">Data to save.</param> /// <param name="folderLocation">Folder location the user should save in.</param> /// <param name="fileTypes">File types the user can see in file popup.</param> /// <param name="streamSavedCallback">The callback that fires when done.</param> public static void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (savingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.SaveFileDialog); que.streamSavedCallback = streamSavedCallback; que.Data = data; que.FolderLocation = folderLocation; que.FileTypes = fileTypes; ques.Add(que); return; } savingStream = true; StreamManager.streamSavedCallback = streamSavedCallback; plugin.SaveFileDialog(data, folderLocation, fileTypes, async_streamSavedCallback); }
/// <summary> /// Use to have the user pic where a file should be saved. /// NOTE: Does not work on all platforms. /// </summary> /// <param name="data">Data to save.</param> /// <param name="folderLocation">Folder location the user should save in.</param> /// <param name="fileTypes">File types the user can see in file popup.</param> /// <param name="streamSavedCallback">The callback that fires when done.</param> public static void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (savingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.SaveFileDialog); que.streamSavedCallback = streamSavedCallback; que.Data = data; que.FolderLocation = folderLocation; que.FileTypes = fileTypes; ques.Add(que); return; } savingStream = true; StreamManager.streamSavedCallback = streamSavedCallback; plugin.SaveFileDialog(data, folderLocation, fileTypes, async_streamSavedCallback); }
public void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { if (steamSavedCallback != null) { steamSavedCallback(false); } }
public void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (streamSavedCallback != null) streamSavedCallback(false); }
public void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { if (streamSavedCallback != null) { streamSavedCallback(false); } }
public void SaveFileDialog(Stream stream, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { var data = new byte[stream.Length]; stream.Read(data, 0, data.Length); SaveFileDialog(data, folderLocation, fileTypes, streamSavedCallback); }
public virtual void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { Debug.LogError("SaveFileDialog not supported on this Platform!"); if (streamSavedCallback != null) { streamSavedCallback(false); } }
public virtual void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { Debug.LogError("SaveFileDialog not supported on this Platform!"); if (streamSavedCallback != null) streamSavedCallback(false); }
public void SaveFile(string fileName, Stream stream, FolderLocations folderLocation, StreamSavedCallbackMethod steamSavedCallback) { var data = new byte[stream.Length]; stream.Read(data, 0, data.Length); SaveFile(fileName, data, folderLocation, steamSavedCallback); }
public void SaveFile(string fileName, Stream stream, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { var data = new byte[stream.Length]; stream.Read(data, 0, data.Length); SaveFile(fileName, data, folderLocation, streamSavedCallback); }
public void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { Native.SaveFile(fileName, data, folderLocation, streamSavedCallback); }
public void SaveFileDialog(Stream stream, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { var data = new byte[stream.Length]; stream.Read(data, 0, data.Length); SaveFileDialog(data, folderLocation, fileTypes, streamSavedCallback); }
private async void saveFileAsync(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { try { #if WINDOWS_PHONE if (folderLocation == FolderLocations.Pictures) { using (var m = new MediaLibrary()) using (var image = m.SavePicture(fileName, data)) { if (streamSavedCallback != null) { streamSavedCallback(image != null); } } return; } #endif fileName = fileName.Replace('/', '\\'); using (var stream = await saveStream(fileName, folderLocation)) { stream.Write(data, 0, data.Length); } } catch (Exception e) { Debug.LogError(e.Message); if (streamSavedCallback != null) { streamSavedCallback(false); } return; } if (streamSavedCallback != null) { streamSavedCallback(true); } }
private async void saveFileDialogAsync(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() { var picker = new FileSavePicker(); if (fileTypes != null && fileTypes.Length != 0) { picker.FileTypeChoices.Add(new KeyValuePair<string,IList<string>>("Supported File Types", fileTypes)); } picker.SuggestedStartLocation = getFolderType(folderLocation); var file = await picker.PickSaveFileAsync(); if (file != null) { using (var fileStream = await file.OpenStreamForWriteAsync()) { fileStream.Write(data, 0, data.Length); ReignServices.InvokeOnUnityThread(delegate { if (streamSavedCallback != null) streamSavedCallback(true); }); } } else { ReignServices.InvokeOnUnityThread(delegate { if (streamSavedCallback != null) streamSavedCallback(false); }); } }); }
public void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { #if UNITY_METRO && !UNITY_WP_8_1 saveFileDialogAsync(data, folderLocation, fileTypes, streamSavedCallback); #else Debug.LogError("SaveFileDialog not supported on WP8!"); if (streamSavedCallback != null) { streamSavedCallback(false); } #endif }
public void SaveFileDialog(byte[] data, FolderLocations folderLocation, string[] fileTypes, StreamSavedCallbackMethod streamSavedCallback) { Native.SaveFileDialog(data, folderLocation, fileTypes, streamSavedCallback); }
public void SaveFile(string fileName, byte[] data, FolderLocations folderLocation, StreamSavedCallbackMethod streamSavedCallback) { saveFileAsync(fileName, data, folderLocation, streamSavedCallback); }