/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Load the NodeCanvas NodeCanvas nodeCanvas = NodeEditor.LoadNodeCanvas(path); if (nodeCanvas == null) { return; } mainNodeCanvas = nodeCanvas; // Load the associated MainEditorState List <NodeEditorState> editorStates = NodeEditor.LoadEditorStates(path); mainEditorState = editorStates.Find(x => x.name == "MainEditorState"); if (mainEditorState == null) { mainEditorState = CreateInstance <NodeEditorState> (); } // Set some editor properties string[] folders = path.Split(new char[] { '/' }, StringSplitOptions.None); openedCanvas = folders [folders.Length - 1]; openedCanvasPath = path; NodeEditor.RecalculateAll(mainNodeCanvas); Repaint(); }
public void DrawSideWindow() { GUILayout.Label(new GUIContent("CSG Editor (" + openedCanvas + ")", "The currently opened canvas in the CSG Editor"), NodeEditor.nodeLabelBold); GUILayout.Label(new GUIContent("Do note that changes will be saved automatically!", "All changes are automatically saved to the currently opened canvas (see above) if it's present in the Project view."), NodeEditor.nodeLabel); if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the canvas as a new Canvas Asset File in the Assets Folder"))) { SaveNodeCanvas(EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "Saving to a file is only needed once.", NodeEditor.editorPath + "Saves/")); } if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the canvas from a Canvas Asset File in the Assets Folder"), NodeEditor.nodeButton)) { string path = EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Saves/", "asset"); if (!path.Contains(Application.dataPath)) { 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); } if (GUILayout.Button(new GUIContent("New Canvas", "Creates a new Canvas (remember to save the previous one to a referenced Canvas Asset File at least once before! Else it'll be lost!)"), NodeEditor.nodeButton)) { NewNodeCanvas(); } if (GUILayout.Button(new GUIContent("Recalculate All", "Starts to calculate from the beginning off."), NodeEditor.nodeButton)) { NodeEditor.RecalculateAll(mainNodeCanvas); } NodeEditor.knobSize = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the handles of the Node Inputs/Outputs"), NodeEditor.knobSize, 12, 20); mainEditorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom"), mainEditorState.zoom, 0.6f, 2); }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // 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(); }
/// <summary> /// Loads the canvas from the cache save file /// Called whenever a reload was made /// </summary> private void LoadCache() { if (!useCache) { NewNodeCanvas(); return; } // Try to load the NodeCanvas if (!File.Exists(lastSessionPath) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(lastSessionPath, false)) == null) //if(true) { NewNodeCanvas(); return; } // Fetch the associated MainEditorState editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); if (!UnityEditor.AssetDatabase.Contains(editorState)) { NodeEditorSaveManager.AddSubAsset(editorState, lastSessionPath); } CheckCurrentCache(); NodeEditor.RecalculateAll(nodeCanvas); NodeEditor.RepaintClients(); }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Load the NodeCanvas NodeCanvas nodeCanvas = NodeEditor.LoadNodeCanvas(path); if (nodeCanvas == null) { NewNodeCanvas(); return; } mainNodeCanvas = nodeCanvas; // Load the associated MainEditorState List <NodeEditorState> editorStates = NodeEditor.LoadEditorStates(path); mainEditorState = editorStates.Find(x => x.name == "MainEditorState"); if (mainEditorState == null) { mainEditorState = CreateInstance <NodeEditorState> (); } // Set some editor properties openedCanvasPath = path; NodeEditor.RecalculateAll(mainNodeCanvas); Repaint(); }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Load the NodeCanvas mainNodeCanvas = NodeEditor.LoadNodeCanvas(path); if (mainNodeCanvas == null) { NewNodeCanvas(); return; } // Load the associated MainEditorState List <NodeEditorState> editorStates = NodeEditor.LoadEditorStates(path); if (editorStates.Count == 0) { mainEditorState = ScriptableObject.CreateInstance <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 DrawSideWindow() { GUILayout.Label(new GUIContent("Node Editor (" + mainNodeCanvas.name + ")", "Opened Canvas path: " + openedCanvasPath), NodeEditorGUI.nodeLabelBold); 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)) { 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 { path = path.Replace(Application.dataPath, "Assets"); LoadNodeCanvas(path); } } 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(mainNodeCanvas); } if (GUILayout.Button("Force Re-Init")) { NodeEditor.ReInit(true); } if (NodeEditor.isTransitioning(mainNodeCanvas) && GUILayout.Button("Stop Transitioning")) { NodeEditor.StopTransitioning(mainNodeCanvas); } NodeEditorGUI.knobSize = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20); mainEditorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), mainEditorState.zoom, 0.6f, 2); if (mainEditorState.selectedNode != null && Event.current.type != EventType.Ignore) { mainEditorState.selectedNode.DrawNodePropertyEditor(); } }
public static void CreateEditor() { _editor = GetWindow <NodeEditorWindow>(); _editor.minSize = new Vector2(800, 600); NodeEditor.ClientRepaints += _editor.Repaint; NodeEditor.initiated = NodeEditor.InitiationError = false; iconTexture = ResourceManager.LoadTexture(EditorGUIUtility.isProSkin? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png"); _editor.titleContent = new GUIContent("Noise Designer", iconTexture); if (_editor.mainNodeCanvas != null && _editor.mainNodeCanvas.nodes != null && _editor.mainNodeCanvas.nodes.Count > 0) { NodeEditor.RecalculateAll(_editor.mainNodeCanvas); } }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadNodeCanvas(string path) { // Try to load the NodeCanvas if (!File.Exists(path) || (nodeCanvas = NodeEditorSaveManager.LoadNodeCanvas(path, true)) == null) { NewNodeCanvas(); return; } editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); openedCanvasPath = path; if (useCache) { SaveCache(); } NodeEditor.RecalculateAll(nodeCanvas); NodeEditor.RepaintClients(); }
public void DrawSideWindow() { GUILayout.Label(new GUIContent("Node Editor (" + mainNodeCanvas.name + ")", "Opened Canvas path: " + openedCanvasPath), NodeEditorGUI.nodeLabelBold); if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder"))) { SaveNodeCanvas(EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", ResourceManager.resourcePath + "Saves/")); } 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", ResourceManager.resourcePath + "Saves/", "asset"); if (!path.Contains(Application.dataPath)) { 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); } 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(mainNodeCanvas); } 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); mainEditorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), mainEditorState.zoom, 0.6f, 2); }
/// <summary> /// Loads the mainNodeCanvas and it's associated mainEditorState from an asset at path /// </summary> public void LoadSceneNodeCanvas(string path) { #if UNITY_EDITOR if (useCache) { DeleteCache(); } #endif // Try to load the NodeCanvas if ((nodeCanvas = NodeEditorSaveManager.LoadSceneNodeCanvas(path, true)) == null) { NewNodeCanvas(); return; } editorState = NodeEditorSaveManager.ExtractEditorState(nodeCanvas, MainEditorStateIdentifier); openedCanvasPath = path; NodeEditor.RecalculateAll(nodeCanvas); NodeEditor.RepaintClients(); }