public void LoadCanvas(string path) { canvasPath = path; if (!string.IsNullOrEmpty(canvasPath)) { canvas = NodeEditorSaveManager.LoadNodeCanvas(canvasPath, true); CalculateCanvas(); } else { canvas = null; } }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadSceneNodeCanvas(string path) { // Try to load the NodeCanvas if ((mainNodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas(path, true)) == null) { NewNodeCanvas(); return; } mainEditorState = NodeEditorSaveManager.ExtractEditorState(mainNodeCanvas, "MainEditorState"); openedCanvasPath = path; NodeEditor.RecalculateAll(mainNodeCanvas); Repaint(); }
private void AssureSetup() { if (canvasCache == null) { // Create cache and load startup-canvas canvasCache = new NodeEditorUserCache(); canvasCache.SetCanvas(NodeEditorSaveManager.CreateWorkingCopy(canvas)); } canvasCache.AssureCanvas(); if (editorInterface == null) { // Setup editor interface editorInterface = NodeEditorInterface.GetInstance(); editorInterface.canvasCache = canvasCache; } }
public void ResetCompletely(string saveName) { saveFiles = NodeEditorSaveManager.GetSceneSaves(); this.saveName = saveName; for (int i = 0; i < saveFiles.Length; i++) { if (saveFiles[i] == saveName) { saveChoice = i; break; } } Awake(); state = InterfaceState.Dirty; }
private void SaveNewTransition(Transition transition) { if (!mainNodeCanvas.nodes.Contains(transition.startNode) || !mainNodeCanvas.nodes.Contains(transition.endNode)) { throw new UnityException("Cache system: Writing new Transition to save file failed as Node members are not part of the Cache!"); } string path = tempSessionPath + "/LastSession.asset"; if (AssetDatabase.GetAssetPath(mainNodeCanvas) != path) { throw new UnityException("Cache system error: Current Canvas is not saved as the temporary cache!"); } NodeEditorSaveManager.AddSubAsset(transition, path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public void SideGUI() { GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")", "The currently opened canvas in the Node Editor")); screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen"); GUILayout.Label("FPS: " + FPSCounter.currentFPS); GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")"), NodeEditorGUI.nodeLabelBold); if (GUILayout.Button(new GUIContent("New Canvas", "Loads an empty Canvas"))) { NewNodeCanvas(); } GUILayout.Space(6f); GUILayout.BeginHorizontal(); sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true)); if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false))) { SaveSceneNodeCanvas(sceneCanvasName); } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene"))) { GenericMenu genericMenu = new GenericMenu(); string[] sceneSaves = NodeEditorSaveManager.GetSceneSaves(); foreach (string text in sceneSaves) { genericMenu.AddItem(new GUIContent(text), false, LoadSceneCanvasCallback, text); } genericMenu.Show(loadScenePos, 40f); } if (Event.current.type == EventType.Repaint) { Rect lastRect = GUILayoutUtility.GetLastRect(); loadScenePos = new Vector2(lastRect.x + 2f, lastRect.yMax + 2f); } GUILayout.Space(6f); if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { NodeEditor.RecalculateAll(canvas); } if (GUILayout.Button("Force Re-Init")) { NodeEditor.ReInit(true); } NodeEditorGUI.knobSize = RTEditorGUI.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); state.zoom = RTEditorGUI.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), state.zoom, 0.6f, 2f); }
void Start() { canvas = NodeEditorSaveManager.LoadSceneNodeCanvas("CraftingCanvas", false); Debug.Log(canvas); IngredientNode iNode = Instantiate(canvas.nodes.Find(x => ((IngredientNode)x).ingredientName == "Green Herb")) as IngredientNode; BaseItem item_ = new BaseItem(iNode); _inventory.Add(item_); iNode = Instantiate(canvas.nodes.Find(x => ((IngredientNode)x).ingredientName == "Blue Herb")) as IngredientNode; item_ = new BaseItem(iNode); _inventory.Add(item_); iNode = Instantiate(canvas.nodes.Find(x => ((IngredientNode)x).ingredientName == "Green Herb")) as IngredientNode; item_ = new BaseItem(iNode); _inventory.Add(item_); iNode = Instantiate(canvas.nodes.Find(x => ((IngredientNode)x).ingredientName == "Blue Herb")) as IngredientNode; item_ = new BaseItem(iNode); _inventory.Add(item_); }
public override void OnInspectorGUI() { var dialogue = target as DialogueInterface; if (dialogue == null) { return; } if (string.IsNullOrEmpty(dialogue.saveName)) { dialogue.saveFiles = NodeEditorSaveManager.GetSceneSaves(); } if (dialogue.saveFiles.Length == 0) { return; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Nodegraph:"); var newChoice = EditorGUILayout.Popup(dialogue.saveChoice, dialogue.saveFiles); EditorGUILayout.EndHorizontal(); if (newChoice != dialogue.saveChoice) { dialogue.saveChoice = newChoice; dialogue.saveName = dialogue.saveFiles[dialogue.saveChoice]; dialogue.Reset(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Force Reloading")) { dialogue.saveName = dialogue.saveFiles[dialogue.saveChoice]; dialogue.Reset(); } if (GUILayout.Button("Reload saves")) { dialogue.saveFiles = NodeEditorSaveManager.GetSceneSaves(); } EditorGUILayout.EndHorizontal(); DrawDefaultInspector(); }
private void Awake() { if (string.IsNullOrEmpty(saveName)) { Debug.LogError("CRITICAL: CraftingInterface has no save name"); return; } canvas = NodeEditorSaveManager.LoadSceneNodeCanvas(saveName, false); NodeEditor.RecalculateAll(canvas); if (canvas != null) { Debug.Log("NodeGraph loaded."); } else { Debug.Log("Good job, no NodeGraph found."); } }
public NPBehaveCanvasDataManager GetCurrentCanvasDatas() { if (this.npBehaveCanvasDataManager == null) { Object[] subAssets = AssetDatabase.LoadAllAssetRepresentationsAtPath(this.savePath); foreach (var subAsset in subAssets) { if (subAsset is NPBehaveCanvasDataManager npBbDataManager) { return(npBbDataManager); } } this.npBehaveCanvasDataManager = CreateInstance <NPBehaveCanvasDataManager>(); //Log.Info("新建数据仓库"); this.npBehaveCanvasDataManager.name = "当前Canvas数据库"; NodeEditorSaveManager.AddSubAsset(this.npBehaveCanvasDataManager, this); } return(this.npBehaveCanvasDataManager); }
private void AssureSetup() { if (canvasCache == null) { // Create cache and load startup-canvas canvasCache = new NodeEditorUserCache(); if (canvas != null) { canvasCache.SetCanvas(NodeEditorSaveManager.CreateWorkingCopy(canvas)); } else if (!string.IsNullOrEmpty(loadSceneName)) { canvasCache.LoadSceneNodeCanvas(loadSceneName); } } canvasCache.AssureCanvas(); if (editorInterface == null) { // Setup editor interface editorInterface = new NodeEditorInterface(); editorInterface.canvasCache = canvasCache; } }
void Start() { Animator animator = GetComponent <Animator>(); // Load NodeCanvas asset var path = "Assets/Plugins/Node_Editor/Resources/Saves/PlayableCanvas.asset"; var canvas = NodeEditorSaveManager.LoadNodeCanvas(path, false); // Set input/output values on runtime, otherwise all input/output have null foreach (Node n in canvas.nodes) { n.Calculate(); } // Find AnimationPlayableMixerNode AnimationPlayableBaseNode node = FindNode(canvas); playableInst = new AnimationPlayableInstance(animator, node); // Mixing animations. playableInst.Execute(); }
private void SaveNewNodeKnob(NodeKnob knob) { if (mainNodeCanvas.livesInScene) { return; } if (!mainNodeCanvas.nodes.Contains(knob.body)) { return; } CheckCurrentCache(); NodeEditorSaveManager.AddSubAsset(knob, knob.body); foreach (ScriptableObject so in knob.GetScriptableObjects()) { NodeEditorSaveManager.AddSubAsset(so, knob); } EditorUtility.SetDirty(mainNodeCanvas); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Else it will be stuck forever NodeEditor.StopTransitioning(mainNodeCanvas); // Load the NodeCanvas mainNodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, true); if (mainNodeCanvas == null) { Debug.Log("Error loading NodeCanvas from '" + path + "'!"); NewNodeCanvas(); return; } // Load the associated MainEditorState List <NodeEditorState> editorStates = NodeEditorSaveManager.LoadEditorStates(path, true); if (editorStates.Count == 0) { mainEditorState = ScriptableObject.CreateInstance <NodeEditorState> (); Debug.LogError("The save file '" + path + "' did not contain an associated NodeEditorState!"); } else { mainEditorState = editorStates.Find(x => x.name == "MainEditorState"); if (mainEditorState == null) { mainEditorState = editorStates[0]; } } mainEditorState.canvas = mainNodeCanvas; openedCanvasPath = path; NodeEditor.RecalculateAll(mainNodeCanvas); SaveCache(); Repaint(); }
private void DoModalWindow(int unusedWindowID) { GUILayout.BeginHorizontal(); sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true)); bool overwrite = NodeEditorSaveManager.HasSceneSave(sceneCanvasName); if (overwrite) { GUILayout.Label(new GUIContent("!!!", "A canvas with the specified name already exists. It will be overwritten!"), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { showModalPanel = false; } if (GUILayout.Button(new GUIContent(overwrite? "Overwrite" : "Save", "Save the canvas to the Scene"))) { showModalPanel = false; canvasCache.SaveSceneNodeCanvas(sceneCanvasName); } GUILayout.EndHorizontal(); }
/// <summary> /// 供外部调用的保存当前图的接口 /// </summary> /// <returns></returns> public bool AssertSavaCanvasSuccessfully() { if (canvasCache.nodeCanvas is DefaultCanvas || !File.Exists(NodeEditorSaveManager.GetLastCanvasPath())) { return(true); } string path = canvasCache.nodeCanvas.savePath; //清理要删掉的Node foreach (var nodeForDelete in canvasCache.nodeCanvas.nodesForDelete) { //去除Node附带的端口 foreach (var connectPort in nodeForDelete.connectionPorts) { UnityEngine.Object.DestroyImmediate(connectPort, true); } UnityEngine.Object.DestroyImmediate(nodeForDelete, true); } canvasCache.nodeCanvas.nodesForDelete.Clear(); if (!string.IsNullOrEmpty(path)) { canvasCache.SaveNodeCanvas(path); ShowNotification(new GUIContent("Canvas Saved!")); Debug.Log($"{path}已保存成功"); return(true); } else { Debug.LogError($"{path}保存失败,请先确保要覆盖的文件已存在!(尝试使用Save As创建目标文件)"); ShowNotification(new GUIContent("No save location found. Use 'Save As'!")); return(false); } }
public override void OnInspectorGUI() { CraftingInterface crafting = target as CraftingInterface; if (crafting.saveChoices == null) { crafting.saveChoices = NodeEditorSaveManager.GetSceneSaves(); } if (crafting.saveChoices.Length == 0) { return; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Nodegraph:"); var newChoice = EditorGUILayout.Popup(crafting.saveChoice, crafting.saveChoices); EditorGUILayout.EndHorizontal(); if (newChoice != crafting.saveChoice) { crafting.saveChoice = newChoice; crafting.saveName = crafting.saveChoices[crafting.saveChoice]; crafting.Reset(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Force Reloading")) { crafting.Reset(); } if (GUILayout.Button("Reload saves")) { crafting.saveChoices = NodeEditorSaveManager.GetSceneSaves(); } EditorGUILayout.EndHorizontal(); DrawDefaultInspector(); }
/// <summary> /// Saves the mainNodeCanvas and it's associated mainEditorState as an asset at path /// </summary> public void SaveNodeCanvas(string path) { mainNodeCanvas.editorStates = new NodeEditorState[] { mainEditorState }; NodeEditorSaveManager.SaveNodeCanvas(path, mainNodeCanvas, true); Repaint(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); BehaviourTreeAgent agent = target as BehaviourTreeAgent; if (agent.tree == null) { return; } if (NodeEditor.curNodeCanvas == null || NodeEditor.curNodeCanvas.savePath != agent.tree.savePath) { BehaviourTree.selectedAgent = agent; NodeEditor.ReInit(false); NodeCanvas c = NodeEditorSaveManager.CreateWorkingCopy(agent.tree); NodeEditor.curNodeCanvas = c; NodeEditorWindow.editor.canvasCache.SetCanvas(c); } if (agent.gameObjectParameters != null) { objectFold = EditorGUILayout.Foldout(objectFold, "Game Objects"); if (objectFold) { List <string> keys = new List <string>(agent.gameObjectParameters.Keys); foreach (string key in keys) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(key); agent.gameObjectParameters[key] = EditorGUILayout.ObjectField(agent.gameObjectParameters[key], typeof(GameObject), true) as GameObject; EditorGUILayout.EndHorizontal(); } } } if (agent.floatParameters != null) { floatFold = EditorGUILayout.Foldout(floatFold, "Floats"); List <string> keys = new List <string>(agent.floatParameters.Keys); if (floatFold) { foreach (string key in keys) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(key); agent.floatParameters[key] = EditorGUILayout.FloatField(agent.floatParameters[key]); EditorGUILayout.EndHorizontal(); } } } if (agent.integerParameters != null) { integerFold = EditorGUILayout.Foldout(integerFold, "Integers"); List <string> keys = new List <string>(agent.integerParameters.Keys); if (integerFold) { foreach (string key in keys) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(key); agent.integerParameters[key] = EditorGUILayout.IntField(agent.integerParameters[key]); EditorGUILayout.EndHorizontal(); } } } if (agent.boolParameters != null) { boolFold = EditorGUILayout.Foldout(boolFold, "Booleans"); List <string> keys = new List <string>(agent.boolParameters.Keys); if (boolFold) { foreach (string key in keys) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(key); agent.boolParameters[key] = EditorGUILayout.Toggle(agent.boolParameters[key]); EditorGUILayout.EndHorizontal(); } } } if (agent.vector3Parameters != null) { vectorFold = EditorGUILayout.Foldout(vectorFold, "Vectors"); List <string> keys = new List <string>(agent.vector3Parameters.Keys); if (vectorFold) { foreach (string key in keys) { EditorGUILayout.BeginHorizontal(); agent.vector3Parameters[key] = EditorGUILayout.Vector3Field(key, agent.vector3Parameters[key]); EditorGUILayout.EndHorizontal(); } } } }
protected internal override void NodeGUI() { GUILayout.BeginHorizontal(); #if UNITY_EDITOR if (GUILayout.Button(new GUIContent("Load", "Loads the group from an extern Canvas Asset File."))) { string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Saves/", "asset"); if (!path.Contains(Application.dataPath)) { // TODO: Generic Notification //if (path != String.Empty) //ShowNotification (new GUIContent ("You should select an asset inside your project folder!")); return; } path = path.Replace(Application.dataPath, "Assets"); LoadNodeCanvas(path); //AdoptInputsOutputs (); } if (GUILayout.Button(new GUIContent("Save", "Saves the group as a new Canvas Asset File"))) { NodeEditorSaveManager.SaveNodeCanvas(UnityEditor.EditorUtility.SaveFilePanelInProject("Save Group Node Canvas", "Group Canvas", "asset", "", NodeEditor.editorPath + "Saves/"), nodeGroupCanvas); } #endif if (GUILayout.Button(new GUIContent("New Group Canvas", "Creates a new Canvas"))) { nodeGroupCanvas = CreateInstance <NodeCanvas> (); editorState = CreateInstance <NodeEditorState> (); editorState.drawing = edit; editorState.name = "GroupNode_EditorState"; Node node = NodeTypes.getDefaultNode("exampleNode"); if (node != null) { NodeCanvas prevNodeCanvas = NodeEditor.curNodeCanvas; NodeEditor.curNodeCanvas = nodeGroupCanvas; node = node.Create(Vector2.zero); node.InitBase(); NodeEditor.curNodeCanvas = prevNodeCanvas; } } GUILayout.EndHorizontal(); if (nodeGroupCanvas != null) { foreach (NodeInput input in Inputs) { input.DisplayLayout(); } foreach (NodeOutput output in Outputs) { output.DisplayLayout(); } if (!edit) { if (GUILayout.Button("Edit Node Canvas")) { rect = openedRect; edit = true; editorState.canvasRect = GUILayoutUtility.GetRect(canvasSize.x, canvasSize.y, GUIStyle.none); editorState.drawing = true; } } else { if (GUILayout.Button("Stop editing Node Canvas")) { nodeRect.position = openedRect.position + new Vector2(canvasSize.x / 2 - nodeRect.width / 2, 0); rect = nodeRect; edit = false; editorState.drawing = false; } Rect canvasRect = GUILayoutUtility.GetRect(canvasSize.x, canvasSize.y, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); if (Event.current.type != EventType.Layout) { editorState.canvasRect = canvasRect; Rect canvasControlRect = editorState.canvasRect; canvasControlRect.position += rect.position + contentOffset; NodeEditor.curEditorState.ignoreInput.Add(NodeEditorFramework.NodeEditor.CanvasGUIToScreenRect(canvasControlRect)); } NodeEditor.DrawSubCanvas(nodeGroupCanvas, editorState); GUILayout.BeginArea(new Rect(canvasSize.x + 8, 45, 200, canvasSize.y), GUI.skin.box); GUILayout.Label(new GUIContent("Node Editor (" + nodeGroupCanvas.name + ")", "The currently opened canvas in the Node Editor")); #if UNITY_EDITOR editorState.zoom = UnityEditor.EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), editorState.zoom, 0.6f, 2); #endif GUILayout.EndArea(); // Node is drawn by parent nodeCanvas, usually the mainNodeCanvas, because the zoom feature requires it to be drawn outside of any GUI group } } }
bool FixupForSubCanvas() { if (!string.IsNullOrEmpty(m_CanvasGuid) && m_SubCanvas == null) { string NodeCanvasPath = AssetDatabase.GUIDToAssetPath(m_CanvasGuid); m_SubCanvas = NodeEditorSaveManager.LoadNodeCanvas(NodeCanvasPath, false); m_WasCloned = true; } if (m_SubCanvas != null) { if (!m_WasCloned) { NodeEditorSaveManager.CreateWorkingCopy(m_SubCanvas, false);//miked remove ref m_WasCloned = true; } List <NodeInput> needsInput = new List <NodeInput>(); List <UnityTextureOutput> needsOutput = new List <UnityTextureOutput>(); foreach (Node n in m_SubCanvas.nodes) { if (n.Inputs.Count > 0) { if (n is UnityTextureOutput && n.Inputs[0].connection != null) { needsOutput.Add(n as UnityTextureOutput); } for (int i = 0; i < n.Inputs.Count; i++) { if (n.Inputs[i].connection == null) { //this node has no input so we will wire it up to ours needsInput.Add(n.Inputs[i]); // Debug.Log(" missing input for node "+n+" name "+n.name); } } } } if (needsOutput.Count > Outputs.Count) { while (needsOutput.Count > Outputs.Count) { // Debug.Log(" create input "+Inputs.Count); CreateOutput("Texture" + Outputs.Count + " " + needsOutput[needsOutput.Count - 1].m_TexName, needsOutput[needsOutput.Count - 1].Inputs[0].connection.typeID, NodeSide.Right, 50 + Outputs.Count * 20); } } if (needsOutput.Count > 0) { Outputs[0].name = "Texture0" + " " + needsOutput[0].m_TexName; } if (needsInput.Count > Inputs.Count) { // while (needsInput.Count > Inputs.Count) int startInputCount = Inputs.Count; // for(int index= needsInput.Count-1;index>= startInputCount; index--) for (int index = Inputs.Count; index < needsInput.Count; index++) { string name = needsInput[index].name; // Debug.Log(" create input "+Inputs.Count); CreateInput(name, needsInput[index].typeID, NodeSide.Left, 30 + Inputs.Count * 20); } return(false); } } return(true); }
private void DrawSideWindow() { GUILayout.Label(new GUIContent("Node Editor (" + canvasCache.nodeCanvas.name + ")", "Opened Canvas path: " + canvasCache.openedCanvasPath), NodeEditorGUI.nodeLabelBold); EditorGUILayout.ObjectField("Loaded Canvas", canvasCache.nodeCanvas, typeof(NodeCanvas), false); EditorGUILayout.ObjectField("Loaded State", canvasCache.editorState, typeof(NodeEditorState), false); /* * if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType"))) * { * NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu(); * NodeCanvasManager.FillCanvasTypeMenu(ref menu, canvasCache.NewNodeCanvas); * menu.Show(createCanvasUIPos.position, createCanvasUIPos.width); * } */ if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0); } GUILayout.Space(6); if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder"))) { string path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/"); if (!string.IsNullOrEmpty(path)) { canvasCache.SaveNodeCanvas(path); } } if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder"))) { string path = EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset"); if (!path.Contains(Application.dataPath)) { if (!string.IsNullOrEmpty(path)) { ShowNotification(new GUIContent("You should select an asset inside your project folder!")); } } else { canvasCache.LoadNodeCanvas(path); } } GUILayout.Space(6); GUILayout.BeginHorizontal(); sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true)); if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false))) { canvasCache.SaveSceneNodeCanvas(sceneCanvasName); } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene"))) { NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu(); foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves()) { menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave); } menu.Show(loadSceneUIPos.position, loadSceneUIPos.width); } if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); loadSceneUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0); } GUILayout.Space(6); if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { NodeEditor.RecalculateAll(canvasCache.nodeCanvas); } if (GUILayout.Button("Force Re-Init")) { NodeEditor.ReInit(true); } NodeEditorGUI.knobSize = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); canvasCache.editorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), canvasCache.editorState.zoom, 0.6f, 2); if (canvasCache.editorState.selectedNode != null && Event.current.type != EventType.Ignore) { canvasCache.editorState.selectedNode.DrawNodePropertyEditor(); } }
public void SaveSceneNodeCanvas(string path) { canvas.editorStates = new NodeEditorState[] { state }; NodeEditorSaveManager.SaveSceneNodeCanvas(path, ref canvas, true); }
bool FixupForSubCanvas() { if (!string.IsNullOrEmpty(m_CanvasGuid) && m_SubCanvas == null) { string nodeCanvasPath = AssetDatabase.GUIDToAssetPath(m_CanvasGuid); m_SubCanvas = NodeEditorSaveManager.LoadNodeCanvas(nodeCanvasPath, false); m_WasCloned = false; } if (m_SubCanvas != null) { if (!m_WasCloned) { m_SubCanvas = NodeEditorSaveManager.CreateWorkingCopy(m_SubCanvas, false); //miked remove ref m_WasCloned = true; /* test its making unique nodes * foreach (Node n in m_SubCanvas.nodes) * { * if (n is TextureNode) * { * var tnIn = n as TextureNode; * var was = tnIn.m_TexHeight; * tnIn.m_TexHeight = Random.Range(1000, 1500); * Debug.Log("Change sub routines node" + tnIn + " tex height to " + tnIn.m_TexHeight + " was " + was); * * } * } */ } List <NodeInput> needsInput = new List <NodeInput>(); List <TextureNode> needsOutput = new List <TextureNode>(); foreach (Node n in m_SubCanvas.nodes) { if (n.Inputs.Count > 0) { if (n is UnityTextureOutput && n.Inputs[0].connection != null) { needsOutput.Add(n as TextureNode); } if (n is UnityTextureOutputMetalicAndRoughness && n.Inputs[0].connection != null) { needsOutput.Add(n as TextureNode); } for (int i = 0; i < n.Inputs.Count; i++) { if (n.Inputs[i].connection == null) { //this node has no input so we will wire it up to ours needsInput.Add(n.Inputs[i]); // Debug.Log(" missing input for node "+n+" name "+n.name); } } } } if (needsOutput.Count > Outputs.Count) { while (needsOutput.Count > Outputs.Count) { // Debug.Log(" create input "+Inputs.Count); string nname = GetNodeOutputName(needsOutput[Outputs.Count]); CreateOutput("Texture" + Outputs.Count + " " + nname, needsOutput[Outputs.Count].Inputs[0].connection.typeID, NodeSide.Right, 50 + Outputs.Count * 20); } } if (needsOutput.Count > 0) { Outputs[0].name = "Texture0" + " " + GetNodeOutputName(needsOutput[0]); } if (needsInput.Count > Inputs.Count) { int added = 0; for (int index = Inputs.Count; index < needsInput.Count; index++) { string needInputname = needsInput[index].name; // Debug.Log(" create input "+Inputs.Count); NodeInput newInput = CreateInput(needInputname, needsInput[index].typeID, NodeSide.Left, 30 + Inputs.Count * 20); if (newInput.typeID == "Float") { var n = Node.Create("inputNode", rect.position - new Vector2(100, 50 - added * 60)); added++; InputNode inode = n as InputNode; if (inode != null) { newInput.ApplyConnection(inode.Outputs[0], false); InputNode ip = (InputNode)n; Node nodeThatNeedsInput = needsInput[index].body; //Use reflection to find the float remap member var that matches the input FieldInfo[] myField = nodeThatNeedsInput.GetType().GetFields(); foreach (var x in myField) { // if(x.FieldType is FloatRemap) if (x.GetValue(nodeThatNeedsInput) is FloatRemap) { FloatRemap fr = (FloatRemap)x.GetValue(nodeThatNeedsInput); //its a struct this makes a copy // Debug.Log(x + " " + x.FieldType + " " + x.GetType() + " " + x.ReflectedType+" fr val:"+fr.m_Value); if (fr.m_ReplaceWithInput && fr.m_Replacement == null) { Debug.LogError(" wants to be replaced but isnt linked "); } else if (fr.m_Replacement != null) { NodeKnob knob = fr.m_Replacement; NodeInput replace = knob as NodeInput; if (replace != null) { if (replace == needsInput[index]) { ip.m_Value.Set(fr.m_Value); ip.m_Value.m_Min = fr.m_Min; ip.m_Value.m_Max = fr.m_Max; } } } } } } } } m_InputsCreated = true; //CreateNewFloatInputs(); return(false); } } return(true); }
public void SideGUI() { GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")", "The currently opened canvas in the Node Editor")); screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen"); GUILayout.Label("FPS: " + FPSCounter.currentFPS); GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")"), NodeEditorGUI.nodeLabelBold); if (GUILayout.Button(new GUIContent("New Canvas", "Loads an empty Canvas"))) { NewNodeCanvas(); } GUILayout.Space(6); #if UNITY_EDITOR if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder"))) { string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/"); if (!string.IsNullOrEmpty(path)) { NodeEditorSaveManager.SaveNodeCanvas(path, canvas, true); } } if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder"))) { string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset"); if (!path.Contains(Application.dataPath)) { if (!string.IsNullOrEmpty(path)) { Debug.LogWarning("You should select an asset inside your project folder!"); } } else { path = path.Replace(Application.dataPath, "Assets"); LoadNodeCanvas(path); } } GUILayout.Space(6); #endif GUILayout.BeginHorizontal(); sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true)); if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false))) { SaveSceneNodeCanvas(sceneCanvasName); } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene"))) { NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu(); foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves()) { menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave); } menu.Show(loadScenePos); } if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); loadScenePos = new Vector2(popupPos.x + 2, popupPos.yMax + 2); } GUILayout.Space(6); if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { NodeEditor.RecalculateAll(canvas); } if (GUILayout.Button("Force Re-Init")) { NodeEditor.ReInit(true); } NodeEditorGUI.knobSize = RTEditorGUI.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); state.zoom = RTEditorGUI.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), state.zoom, 0.6f, 2); }
public void SideGUI() { GUILayout.Label(new GUIContent("" + cache.nodeCanvas.saveName + " (" + (cache.nodeCanvas.livesInScene? "Scene Save" : "Asset Save") + ")", "Opened Canvas path: " + cache.nodeCanvas.savePath), NodeEditorGUI.nodeLabelBold); GUILayout.Label("Type: " + cache.typeData.DisplayString + "/" + cache.nodeCanvas.GetType().Name + ""); if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType"))) { NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu(); NodeCanvasManager.FillCanvasTypeMenu(ref menu, cache.NewNodeCanvas); menu.Show(createCanvasUIPos.position, createCanvasUIPos.width); } if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0); } if (cache.nodeCanvas.GetType() == typeof(NodeCanvas) && GUILayout.Button(new GUIContent("Convert Canvas", "Converts the current canvas to a new type."))) { NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu(); NodeCanvasManager.FillCanvasTypeMenu(ref menu, cache.ConvertCanvasType); menu.Show(convertCanvasUIPos.position, convertCanvasUIPos.width); } if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); convertCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0); } if (GUILayout.Button(new GUIContent("Save Canvas", "Save the Canvas to the load location"))) { string path = cache.nodeCanvas.savePath; if (!string.IsNullOrEmpty(path)) { if (path.StartsWith("SCENE/")) { cache.SaveSceneNodeCanvas(path.Substring(6)); } else { cache.SaveNodeCanvas(path); } } } #if UNITY_EDITOR GUILayout.Label("Asset Saving", NodeEditorGUI.nodeLabel); if (GUILayout.Button(new GUIContent("Save Canvas As", "Save the canvas as an asset"))) { string panelPath = NodeEditor.editorPath + "Resources/Saves/"; if (cache.nodeCanvas != null && !string.IsNullOrEmpty(cache.nodeCanvas.savePath)) { panelPath = cache.nodeCanvas.savePath; } string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", panelPath); if (!string.IsNullOrEmpty(path)) { cache.SaveNodeCanvas(path); } } if (GUILayout.Button(new GUIContent("Load Canvas", "Load the Canvas from an asset"))) { string panelPath = NodeEditor.editorPath + "Resources/Saves/"; if (cache.nodeCanvas != null && !string.IsNullOrEmpty(cache.nodeCanvas.savePath)) { panelPath = cache.nodeCanvas.savePath; } string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", panelPath, "asset"); if (!path.Contains(Application.dataPath)) { if (!string.IsNullOrEmpty(path)) { Debug.LogWarning(new GUIContent("You should select an asset inside your project folder!")); } } else { cache.LoadNodeCanvas(path); } if (cache.nodeCanvas.GetType() == typeof(NodeCanvas)) { Debug.LogWarning(new GUIContent("The Canvas has no specific type. Please use the convert button to assign a type and re-save the canvas!")); } } #endif GUILayout.Label("Scene Saving", NodeEditorGUI.nodeLabel); GUILayout.BeginHorizontal(); sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true)); if (GUILayout.Button(new GUIContent("Save to Scene", "Save the canvas to the Scene"), GUILayout.ExpandWidth(false))) { cache.SaveSceneNodeCanvas(sceneCanvasName); } GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent("Load from Scene", "Load the canvas from the Scene"))) { NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu(); foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves()) { menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave); } menu.Show(loadSceneUIPos.position, loadSceneUIPos.width); } if (Event.current.type == EventType.Repaint) { Rect popupPos = GUILayoutUtility.GetLastRect(); loadSceneUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0); } GUILayout.Label("Utility/Debug", NodeEditorGUI.nodeLabel); if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { cache.nodeCanvas.TraverseAll(); } if (GUILayout.Button("Force Re-Init")) { NodeEditor.ReInit(true); } NodeEditorGUI.knobSize = RTEditorGUI.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); //cache.editorState.zoom = EditorGUILayout.Slider (new GUIContent ("Zoom", "Use the Mousewheel. Seriously."), cache.editorState.zoom, 0.6f, 4); NodeEditorUserCache.cacheIntervalSec = RTEditorGUI.IntSlider(new GUIContent("Cache Interval (Sec)", "The interval in seconds the canvas is temporarily saved into the cache as a precaution for crashes."), NodeEditorUserCache.cacheIntervalSec, 30, 300); screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen"); GUILayout.Label("FPS: " + FPSCounter.currentFPS); if (cache.editorState.selectedNode != null && Event.current.type != EventType.Ignore) { cache.editorState.selectedNode.DrawNodePropertyEditor(); } }
public void DrawToolbarGUI() { GUILayout.BeginHorizontal(GUI.skin.GetStyle("toolbar")); if (GUILayout.Button("File", GUI.skin.GetStyle("toolbarDropdown"), GUILayout.Width(50))) { GenericMenu menu = new GenericMenu(NodeEditorGUI.useUnityEditorToolbar && !Application.isPlaying); // New Canvas filled with canvas types NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/"); menu.AddSeparator(""); // Load / Save #if UNITY_EDITOR menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas); menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas); if (canvasCache.nodeCanvas.allowSceneSaveOnly) { menu.AddDisabledItem(new GUIContent("Save Canvas")); menu.AddDisabledItem(new GUIContent("Save Canvas As")); } else { menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas); menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs); } menu.AddSeparator(""); // Scene Saving string[] sceneSaves = NodeEditorSaveManager.GetSceneSaves(); if (sceneSaves.Length <= 0) // Display disabled item { menu.AddItem(new GUIContent("Load Canvas from Scene"), false, null); } else { foreach (string sceneSave in sceneSaves) // Display scene saves to load { menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave); } } menu.AddItem(new GUIContent("Save Canvas to Scene"), false, SaveSceneCanvasCallback); menu.Show(new Vector2(3, toolbarHeight + 3)); #endif // Import / Export filled with import/export types ImportExportManager.FillImportFormatMenu(ref menu, ImportCanvasCallback, "Import/"); if (canvasCache.nodeCanvas.allowSceneSaveOnly) { menu.AddDisabledItem(new GUIContent("Export")); } else { ImportExportManager.FillExportFormatMenu(ref menu, ExportCanvasCallback, "Export/"); } menu.AddSeparator(""); // Show dropdown menu.Show(new Vector2(3, toolbarHeight + 3)); } GUILayout.Space(10); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(canvasCache.nodeCanvas.saveName, "Save Type: " + (canvasCache.nodeCanvas.livesInScene ? "Scene" : "Asset") + "\n" + "Save Path: " + canvasCache.nodeCanvas.savePath), GUI.skin.GetStyle("toolbarLabel")); GUILayout.Label(new GUIContent(canvasCache.typeData.DisplayString, "Canvas Type: " + canvasCache.typeData.DisplayString), GUI.skin.GetStyle("toolbarLabel")); GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1); /*if (GUILayout.Button("Reinit", GUI.skin.GetStyle("toolbarButton"), GUILayout.Width(100))) * { * NodeEditor.ReInit(true); * NodeEditorGUI.CreateDefaultSkin(); * canvasCache.nodeCanvas.Validate(); * }*/ if (Application.isPlaying) { GUILayout.Space(5); if (GUILayout.Button("Quit", GUI.skin.GetStyle("toolbarButton"), GUILayout.Width(100))) { Application.Quit(); } } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { toolbarHeight = GUILayoutUtility.GetLastRect().yMax; } }
public void SideGUI() { GUILayout.BeginArea(new Rect(canvasRect.x + state.canvasRect.width, state.canvasRect.y, 200, state.canvasRect.height), NodeEditorGUI.nodeSkin.box); GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")", "The currently opened canvas in the Node Editor")); screenSize = GUILayout.Toggle(screenSize, "Adapt to Screen"); GUILayout.Label("FPS: " + FPSCounter.currentFPS); GUILayout.Label(new GUIContent("Node Editor (" + canvas.name + ")"), NodeEditorGUI.nodeLabelBold); #if UNITY_EDITOR if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder"))) { string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/"); if (!string.IsNullOrEmpty(path)) { NodeEditorSaveManager.SaveNodeCanvas(path, true, canvas, state); } } if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder"))) { string path = UnityEditor.EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset"); if (!path.Contains(Application.dataPath)) { if (!string.IsNullOrEmpty(path)) { Debug.LogWarning("You should select an asset inside your project folder!"); } } else { path = path.Replace(Application.dataPath, "Assets"); LoadNodeCanvas(path); } } #endif if (GUILayout.Button(new GUIContent("New Canvas", "Loads an empty Canvas"))) { NewNodeCanvas(); } if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually."))) { NodeEditor.RecalculateAll(canvas); } if (GUILayout.Button("Force Re-Init")) { NodeEditor.ReInit(true); } if (NodeEditor.isTransitioning(canvas) && GUILayout.Button("Stop Transitioning")) { NodeEditor.StopTransitioning(canvas); } NodeEditorGUI.knobSize = RTEditorGUI.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); state.zoom = RTEditorGUI.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), state.zoom, 0.6f, 2); GUILayout.EndArea(); }
public void OnEnable() { RTNE = (RTNodeEditor)target; sceneCanvasNames = NodeEditorSaveManager.GetSceneSaves(); }
public void DrawToolbarGUI(Rect rect) { rect.height = toolbarHeight; GUILayout.BeginArea(rect, NodeEditorGUI.toolbar); GUILayout.BeginHorizontal(); float curToolbarHeight = 0; if (GUILayout.Button("File", NodeEditorGUI.toolbarDropdown, GUILayout.Width(50))) { GenericMenu menu = new GenericMenu(!Application.isPlaying); // New Canvas filled with canvas types NodeCanvasManager.FillCanvasTypeMenu(ref menu, NewNodeCanvas, "New Canvas/"); menu.AddSeparator(""); // Load / Save #if UNITY_EDITOR menu.AddItem(new GUIContent("Load Canvas"), false, LoadCanvas); menu.AddItem(new GUIContent("Reload Canvas"), false, ReloadCanvas); menu.AddSeparator(""); if (canvasCache.nodeCanvas.allowSceneSaveOnly) { menu.AddDisabledItem(new GUIContent("Save Canvas")); menu.AddDisabledItem(new GUIContent("Save Canvas As")); } else { menu.AddItem(new GUIContent("Save Canvas"), false, SaveCanvas); menu.AddItem(new GUIContent("Save Canvas As"), false, SaveCanvasAs); } menu.AddSeparator(""); #endif // Import / Export filled with import/export types ImportExportManager.FillImportFormatMenu(ref menu, ImportCanvasCallback, "Import/"); if (canvasCache.nodeCanvas.allowSceneSaveOnly) { menu.AddDisabledItem(new GUIContent("Export")); } else { ImportExportManager.FillExportFormatMenu(ref menu, ExportCanvasCallback, "Export/"); } menu.AddSeparator(""); // Scene Saving string[] sceneSaves = NodeEditorSaveManager.GetSceneSaves(); if (sceneSaves.Length <= 0) // Display disabled item { menu.AddItem(new GUIContent("Load Canvas from Scene"), false, null); } else { foreach (string sceneSave in sceneSaves) // Display scene saves to load { menu.AddItem(new GUIContent("Load Canvas from Scene/" + sceneSave), false, LoadSceneCanvasCallback, sceneSave); } } menu.AddItem(new GUIContent("Save Canvas to Scene"), false, SaveSceneCanvasCallback); // Show dropdown menu.Show(new Vector2(5, toolbarHeight)); } curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax); GUILayout.Space(10); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent("" + canvasCache.nodeCanvas.saveName + " (" + (canvasCache.nodeCanvas.livesInScene ? "Scene Save" : "Asset Save") + ")", "Opened Canvas path: " + canvasCache.nodeCanvas.savePath), NodeEditorGUI.toolbarLabel); GUILayout.Label("Type: " + canvasCache.typeData.DisplayString, NodeEditorGUI.toolbarLabel); curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax); GUI.backgroundColor = new Color(1, 0.3f, 0.3f, 1); if (GUILayout.Button("Force Re-init", NodeEditorGUI.toolbarButton, GUILayout.Width(100))) { NodeEditor.ReInit(true); canvasCache.nodeCanvas.Validate(); } #if !UNITY_EDITOR GUILayout.Space(5); if (GUILayout.Button("Quit", NodeEditorGUI.toolbarButton, GUILayout.Width(100))) { Application.Quit(); } #endif curToolbarHeight = Mathf.Max(curToolbarHeight, GUILayoutUtility.GetLastRect().yMax); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.EndArea(); if (Event.current.type == EventType.Repaint) { toolbarHeight = curToolbarHeight; } }