public ActionContainer Save() { GraphSaveUtility saveUtility = GraphSaveUtility.GetInstance(graphView); ActionContainer saved = null; if (graphView.IsCachedFile) { return(saveUtility.SaveGraph(DefaultCacheName)); } if (graphView.IsDirty) { if (string.IsNullOrEmpty(graphView.LoadedFileName) || string.IsNullOrWhiteSpace(graphView.LoadedFileName)) { return(SaveAs()); } saved = saveUtility.SaveGraph(graphView.LoadedFileName); if (saved) { graphView.LoadedFileName = saved.ContainerName; graphView.SetDirty(false); graphView.IsCachedFile = false; } } return(saved); }
/* * private void GenerateBlackBoard() { * var blackboard = new Blackboard(_graphView); * blackboard.Add(new BlackboardSection { title = "全局变量" }); * blackboard.addItemRequested = _blackboard => { _graphView.AddPropertyToBlackBoard(new ExposedProperty()); }; * * blackboard.SetPosition(new Rect(10,30,200,300)); * //_graphView.Blackboard = blackboard; * _graphView.Add(blackboard); * * } */ private void RequestDataOperation(bool save) { if (string.IsNullOrEmpty(_fileName)) { EditorUtility.DisplayDialog("无效文件名", "请输入有效文件名", "确定"); return; } if (save) { GraphSaveUtility.SaveGraph(_fileName, _graphView); } else { GraphSaveUtility.LoadGraph(_fileName, _graphView); } }
private void RequestDataOperation(bool toSave) { if (string.IsNullOrEmpty(_fileName)) { EditorUtility.DisplayDialog("Invalid file name", "Please enter a valid file name", "Sound Good"); return; } GraphSaveUtility saveUtility = GraphSaveUtility.GetInstance(_graphView); if (toSave) { saveUtility.SaveGraph(_fileName); } else { saveUtility.LoadGraph(_fileName); } }
public ActionContainer SaveAs() { GraphSaveUtility saveUtility = GraphSaveUtility.GetInstance(graphView); ActionContainer saved; string path = EditorUtility.SaveFilePanelInProject("Save As", "Module", "asset", "Please save file."); if (string.IsNullOrEmpty(path) || string.IsNullOrWhiteSpace(path)) { return(null); } saved = saveUtility.SaveGraph(path, true); if (saved) { //Was able to save graphView.LoadedFileName = saved.ContainerName; graphView.SetDirty(false); graphView.IsCachedFile = false; } return(saved); }