private static void EditorManager_ProcessExternalFileDrop(object sender, ExternalFileDropArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } string[] res = e.Data.GetData(DataFormats.FileDrop) as string[]; if (res == null || res.GetLength(0) == 0) { return; } string file = res[0]; string extension = file.Substring(file.LastIndexOf('.') + 1).ToLower(); if (extension == "project" || extension == "scene") { //Make sure the current project is saved if (EditorApp.PromptSaveProject() == DialogResult.Cancel) { return; } } else { return; //The file extension was not recognized } if (extension == "project" && EditorAppDelegates.LoadProjectDelegate != null) { // now load the project EditorAppDelegates.LoadProjectDelegate(file, true); } else if (extension == "scene" && EditorAppDelegates.LoadSceneDelegate != null) { // loads the scene if possible /* TODO: * Currently the project gets reloaded every time regardless whether it already is loaded. * Maybe it would be faster to check for this case first. */ EditorAppDelegates.LoadSceneDelegate(file, true); } e.Processed = true; }
void EditorManager_ProcessExternalFileDrop(object sender, ExternalFileDropArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } if (EditorManager.Scene == null) { return; } string filename = ((string[])e.Data.GetData(DataFormats.FileDrop))[0]; if (!EditorManager.Project.CheckRelative(filename)) { EditorManager.ShowMessageBox("Cannot drop file \n\n" + filename + "\n\n because it is not project relative", "Cannot drop object", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } filename = EditorManager.Project.MakeRelative(filename); string extension = Path.GetExtension(filename); string name = Path.GetFileNameWithoutExtension(filename); if (string.Compare(extension, ".model", true) == 0) { EntityShape shape = new EntityShape(name); shape.ModelFile = filename; EditorManager.ActiveView.DropObject(shape, e); } else if (string.Compare(extension, ".vmesh", true) == 0) { StaticMeshShape shape = new StaticMeshShape(name); shape.MeshFileName = filename; EditorManager.ActiveView.DropObject(shape, e); } else if (string.Compare(extension, ".prefab", true) == 0) { PrefabShape shape = new PrefabShape(name); shape.Filename = filename; EditorManager.ActiveView.DropObject(shape, e); } }
private static void EditorManager_ProcessExternalFileDrop(object sender, ExternalFileDropArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return; string[] res = e.Data.GetData(DataFormats.FileDrop) as string[]; if (res == null || res.GetLength(0) == 0) return; string file = res[0]; string extension = file.Substring(file.LastIndexOf('.') + 1).ToLower(); if (extension == "project" || extension == "scene") { //Make sure the current project is saved if (EditorApp.PromptSaveProject() == DialogResult.Cancel) return; } else return; //The file extension was not recognized if (extension == "project" && EditorAppDelegates.LoadProjectDelegate != null) { // now load the project EditorAppDelegates.LoadProjectDelegate(file, true); } else if (extension == "scene" && EditorAppDelegates.LoadSceneDelegate != null) { // loads the scene if possible /* TODO: * Currently the project gets reloaded every time regardless whether it already is loaded. * Maybe it would be faster to check for this case first. */ EditorAppDelegates.LoadSceneDelegate(file, true); } e.Processed = true; }
void EditorManager_ProcessExternalFileDrop(object sender, ExternalFileDropArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return; if (EditorManager.Scene == null) return; string filename = ((string[])e.Data.GetData(DataFormats.FileDrop))[0]; if (!EditorManager.Project.CheckRelative(filename)) { EditorManager.ShowMessageBox("Cannot drop file \n\n" + filename + "\n\n because it is not project relative", "Cannot drop object", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } filename = EditorManager.Project.MakeRelative(filename); string extension = Path.GetExtension(filename); string name = Path.GetFileNameWithoutExtension(filename); if (string.Compare(extension, ".model", true) == 0) { EntityShape shape = new EntityShape(name); shape.ModelFile = filename; EditorManager.ActiveView.DropObject(shape, e); } else if (string.Compare(extension, ".vmesh", true) == 0) { StaticMeshShape shape = new StaticMeshShape(name); shape.MeshFileName = filename; EditorManager.ActiveView.DropObject(shape, e); } else if (string.Compare(extension, ".prefab", true) == 0) { PrefabShape shape = new PrefabShape(name); shape.Filename = filename; EditorManager.ActiveView.DropObject(shape, e); } }