private void SetCurrentCanvas(NodesCanvas canvas) { this.Repaint(); if (canvas != null) { EventManager.TriggerOnFocusGraph(canvas.Graph); } this._currentCanvas = canvas; }
private void HandleTabButtons() { Color standardBackgroundColor = GUI.backgroundColor; int tabIndex = 0; NodesCanvas canvasToClose = null; foreach (NodesCanvas tmpCanvas in this._canvasList) { int width = TabButtonWidth + TabButtonMargin + TabCloseButtonSize; int xOffset = width * tabIndex; tmpCanvas.TabButton.Set(xOffset, TopMenuHeight + TabButtonMargin, TabButtonWidth, TopMenuHeight); tmpCanvas.CloseTabButton.Set(xOffset + width - TabCloseButtonSize - TabButtonMargin - 4, TopMenuHeight + TabButtonMargin, TabCloseButtonSize, TabCloseButtonSize); bool isSelected = this._currentCanvas == tmpCanvas; string tabName = tmpCanvas.Graph.Name; //tabName = Path.GetFileName(tmpCanvas.FilePath); if (isSelected) { GUI.backgroundColor = this._tabColorSelected; } else { GUI.backgroundColor = this._tabColorUnselected; } if (GUI.Button(tmpCanvas.TabButton, tabName)) { this.SetCurrentCanvas(tmpCanvas); } if (isSelected) { if (GUI.Button(tmpCanvas.CloseTabButton, "X")) { canvasToClose = tmpCanvas; } } tabIndex++; } GUI.backgroundColor = standardBackgroundColor; if (canvasToClose != null) { this.CloseCanvas(canvasToClose); } }
private void CreateCanvas(string path) { NodesCanvas canvas; if (path != null) { canvas = new NodesCanvas(Launcher.LoadGraph(path)); } else { canvas = new NodesCanvas(Launcher.LoadGraph(NodeEditorConfig.DefaultGraphName)); } canvas.FilePath = path; this._canvasList.Add(canvas); this.SetCurrentCanvas(canvas); }
private void CloseCanvas(NodesCanvas canvas) { bool doSave = EditorUtility.DisplayDialog("Do you want to save.", "Do you want to save the graph " + canvas.FilePath + " ?", "Yes", "No"); if (doSave) { Launcher.SaveGraph(canvas.Graph, canvas.FilePath); } EventManager.TriggerOnCloseGraph(canvas.Graph); Launcher.RemoveGraph(canvas.Graph); this._canvasList.Remove(canvas); if (this._canvasList.Count > 0) { this.SetCurrentCanvas(this._canvasList[0]); } else { this.SetCurrentCanvas(null); } }
public void Init() { EditorApplication.playmodeStateChanged = this.OnPlaymodeStateChanged; // create GameObject and the Component if it is not added to the scene this.titleContent = new GUIContent(Name); this.wantsMouseMove = true; EventManager.TriggerOnWindowOpen(); this._menuEntryToNodeType = this.CreateMenuEntries(); this._menu = this.CreateGenericMenu(); this._canvasList.Clear(); this._currentCanvas = null; if (Launcher.Graphs.Count > 0) { this.LoadCanvas(Launcher.Graphs); } else { this.LoadCanvas(Launcher.LoadGraph(NodeEditorConfig.DefaultGraphName)); } this.Repaint(); }
private void LoadCanvas(Graph graph) { this._currentCanvas = new NodesCanvas(graph); this._canvasList.Add(this._currentCanvas); }