/// <summary> /// Requests a save or a load /// </summary> /// <param name="save">if true, will save, if false, will load</param> public void RequestDataOperation(bool save) { if (string.IsNullOrEmpty(_fileName)) { EditorUtility.DisplayDialog(title: "Invalide file name !", message: "Please enter a valid file name.", ok: "OK"); if (_autoSave) { _autoSave = false; Toolbar toolbar = rootVisualElement.Q <Toolbar>(); Button saveButton = toolbar.Q <Button>(); saveButton.SetEnabled(true); } return; } var saveUtility = GraphSaveUtility.GetInstance(_graphView, this); if (save) { saveUtility.SaveGraph(_fileName); } else { saveUtility.LoadGraph(_fileName); } }
/// <summary> /// When the graph is enabled, we build the graph view, the blackboard element, the toolbar on top and the minimap /// </summary> private void OnEnable() { var toolbar = rootVisualElement.Q <Toolbar>(); if (toolbar != null) { rootVisualElement.Remove(toolbar); } ConstructGraphView(); GenerateToolBar(); GenerateMiniMap(); GenerateBlackBoard(); if (Resources.Load <SaltButter.Dialogue.Runtime.DialogueContainer>($"Dialogues/{_fileName}") != null) { var saveUtility = GraphSaveUtility.GetInstance(_graphView, this); saveUtility.LoadGraph(_fileName); } }