public static async void DoFileOpen(string sFilename, bool bInteractive, Action <string> onCompletedF = null) { if (string.IsNullOrEmpty(sFilename)) { return; } if (File.Exists(sFilename) == false) { CotangentUI.ShowModalMessageDialog("File Does Not Exist", "File " + sFilename + " does not exist", "Ok", null, null); return; } HaveOpenedOrImportedFile = true; if (sFilename.EndsWith(".cota", StringComparison.OrdinalIgnoreCase)) { // [TODO] make this multi threaded? OpenSceneFile(sFilename); FPlatform.SetPrefsString("LastImportPath", sFilename); } else { ClearScene(); MeshImporter importer = new MeshImporter(); CCStatus.BeginOperation("reading"); await importer.ImportInteractive(sFilename, onCompletedF); CCStatus.EndOperation("reading"); } }
public static void DoSaveCurrentScene(string sFilename) { if (sFilename != null && sFilename.Length > 0) { if (sFilename.EndsWith(".cota", StringComparison.OrdinalIgnoreCase) == false) { sFilename += ".cota"; } CotangentSerializer serializer = new CotangentSerializer(); serializer.SerializeOptions.MinimalMeshStorage = true; serializer.SerializeOptions.FastCompression = false; serializer.SerializeOptions.StoreMeshVertexNormals = false; serializer.SerializeOptions.StoreMeshVertexUVs = false; serializer.SerializeOptions.StoreMeshVertexColors = false; try { serializer.StoreCurrent(sFilename); SetCurrentSaveFilePath(sFilename); ClearCurrentSceneModified(); } catch (Exception e) { DebugUtil.Log("DoSaveCurrentScene: Exception: " + e.Message); CotangentUI.ShowModalMessageDialog("Save Failed", "Error writing to file " + sFilename, "Ok", null, null); } } }
public static void DoDragDropOpen(List <string> filenames) { if (filenames.Count > 1) { CotangentUI.ShowModalMessageDialog("Cannot Open Multiple Scenes", "Sorry, currently Cotangent can only open a single dropped scene.", "Ok", null, null); } OpenSceneFile(filenames[0]); }
public static void OpenSceneFile(string sFilename) { CotangentSerializer serializer = new CotangentSerializer(); try { serializer.RestoreToCurrent(sFilename); SetCurrentSaveFilePath(sFilename); ClearCurrentSceneModified(); } catch (Exception e) { DebugUtil.Log("OpenSceneFile: exception restoring cota file: " + e.Message); CotangentUI.ShowModalMessageDialog("Error Opening Scene", "Sorry, errors ocurred while trying to read this scene file.", "Ok", null, null); } }