private void SaveAsClickHander() { Close(); string path = BarrageProject.GetProjectPath(); if (path == null) { return; } string savePath = FileUtils.SaveFile("选择保存数据", "关卡数据(*.nd)\0*.nd\0"); if (savePath != null) { BaseNode root = BarrageProject.RootNode; NodeData nd = NodeManager.SaveAsNodeData(root, true); FileUtils.SerializableObjectToFile(savePath, nd); BarrageProject.SetProjectPath(savePath); BarrageProject.Log("Save Complete"); } }
private void NewClickHandler() { Close(); string savePath = FileUtils.SaveFile("选择新建工程的位置", "关卡数据(*.nd)\0*.nd\0"); if (savePath != null) { EventManager.GetInstance().PostEvent(EditorEvents.BeforeProjectChanged); BarrageProject.UnloadProject(); // todo 载入固定位置的一个模板 string templatePath = Application.streamingAssetsPath + "/template.nd"; BarrageProject.LoadProject(templatePath); BarrageProject.SetProjectPath(savePath); // 保存文件 BaseNode root = BarrageProject.RootNode; NodeData nd = NodeManager.SaveAsNodeData(root, true); FileUtils.SerializableObjectToFile(savePath, nd); EventManager.GetInstance().PostEvent(EditorEvents.AfterProjectChanged); // 当前文件 BarrageProject.Log("Current project file: " + FileUtils.GetFileNameByPath(savePath)); } }