public static void InitEditorWindow() { currentEditorWindow = (NodeEditorWindow) EditorWindow.GetWindow<NodeEditorWindow>(); currentEditorWindow.title = "Node Editor"; CreateViews(); }
public static void ShowWindow() { if (instance == null) instance = CreateInstance<NodeEditorWindow>(); instance.Show(); if(Nodes == null) Nodes = new List<NodeInspectorBase>(); }
public virtual void Connect(NodeEditorWindow window) { if (window.linkKeep == this) { EditorUtility.DisplayDialog("Error", "[エラー]同じノードでループ出来ません。", "OK"); return; } window.linkKeep.ConnectClient(this); }
private static void CreateViews() { if (curWindow != null) { curWindow.propertyView = new NodePropertyView(); } else { curWindow = (NodeEditorWindow)EditorWindow.GetWindow <NodeEditorWindow>(); } }
public static void InitEditorWindow() { curWindow = (NodeEditorWindow)EditorWindow.GetWindow <NodeEditorWindow>(); //Customize & display Node Editor Window Texture icon = AssetDatabase.LoadAssetAtPath <Texture>("Assets/PTG_NodeEditor/Resources/Textures/Editor/PTG_icon.png"); GUIContent titleContent = new GUIContent("Node Editor", icon); curWindow.titleContent = titleContent; CreateViews(); }
public static bool OnOpen(int instanceID, int line) { NodeGraph nodeGraph = EditorUtility.InstanceIDToObject(instanceID) as NodeGraph; if (nodeGraph != null) { NodeEditorWindow w = Init(); w.graph = nodeGraph; return(true); } return(false); }
public static NodeEditorWindow OpenNodeEditor() { _editor = GetWindow <NodeEditorWindow>(); _editor.minSize = new Vector2(400, 200); NodeEditor.ReInit(false); Texture iconTexture = ResourceManager.LoadTexture(EditorGUIUtility.isProSkin ? "Textures/Icon_Dark.png" : "Textures/Icon_Light.png"); _editor.titleContent = new GUIContent("Node Editor", iconTexture); return(_editor); }
public void InstantiateOrOpenConditionEditor(XNode.Node targetNode) { TransitionNode node = targetNode as TransitionNode; ConditionalGraph condGraph = node.conditionGraph; if (condGraph == null) { condGraph = CreateNewConditionalGraph(node); } NodeEditorWindow.Open(condGraph); }
private void AddValue(BlackboardObject value) { Undo.RecordObject(target.graph, "Create Blackboard Value"); blackboard.AddValue(value); Undo.RegisterCreatedObjectUndo(value, "Create Blackboard Value"); AssetDatabase.AddObjectToAsset(value, target.graph); if (NodeEditorPreferences.GetSettings().autoSave) { AssetDatabase.SaveAssets(); } NodeEditorWindow.RepaintAll(); return; }
public override void OnBodyGUI() { base.OnBodyGUI(); ConditionalRootNode node = target as ConditionalRootNode; ConditionalGraph condGraph = node.graph as ConditionalGraph; if (GUILayout.Button("Back To State Graph")) { StateMachineGraph fsmgraph = condGraph.parentNode.graph as StateMachineGraph; NodeEditorWindow.Open(fsmgraph); } }
public void OpenThisCanvas() { if (this.ChildrenCanvas != null) { //要确保保存成功才能加载目标图 if (!NodeEditorWindow.editorInterface.AssertSavaCanvasSuccessfully()) { return; } string NodeCanvasPath = AssetDatabase.GetAssetPath(this.ChildrenCanvas); NodeEditorWindow.OpenNodeEditor().canvasCache.LoadNodeCanvas(NodeCanvasPath); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUIStyle s = new GUIStyle(GUI.skin.button); s.fontSize = 15; GUI.color = Color.green; if (GUILayout.Button(new GUIContent("Open Editor"), s, GUILayout.Height(50))) { NodeEditorWindow.Open((Trigger)target); } GUI.color = Color.gray; }
/// <summary> /// <para>Implement this function to make a custom inspector.</para> /// </summary> public override void OnInspectorGUI() { serializedObject.Update(); var nodeGraph = (COCNodeGraph)target; // Settings GUILayout.Label(COCEditorConstants.SETTINGS_TITLE, EditorStyles.boldLabel); var autoGenProperty = serializedObject.FindProperty( COCEditorConstants.INCLUDE_AUTOMATIC_GENERATION_PROPERTY_NAME); using (var scope = new EditorGUI.ChangeCheckScope()) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField( new GUIContent( autoGenProperty.displayName, COCEditorConstants.INCLUDE_AUTOMATIC_GENERATION_TOOLTIP), GUILayout.Width(COCEditorConstants.LABEL_WIDTH)); EditorGUILayout.PropertyField(autoGenProperty, GUIContent.none); } if (scope.changed) { serializedObject.ApplyModifiedProperties(); } } // Actions GUILayout.Space(5); GUILayout.Label(COCEditorConstants.ACTIONS_TITLE, EditorStyles.boldLabel); if (GUILayout.Button(new GUIContent( COCEditorConstants.EDIT_GRAPH_BUTTON_LABEL, COCEditorConstants.EDIT_GRAPH_BUTTON_TOOLTIP))) { NodeEditorWindow.Open(nodeGraph); } if (GUILayout.Button( new GUIContent( COCEditorConstants.GENERATE_FOLDERS_BUTTON_LABEL, COCEditorConstants.GENERATE_FOLDERS_BUTTON_TOOLTIP))) { nodeGraph.Evaluate(); } }
public override void OnOpen() { // Create and add an AssetRootNode if not present. if (target.nodes.TrueForAll(x => x.GetType() != typeof(AssetRootNode))) { var node = target.AddNode(typeof(AssetRootNode)); node.position = Vector2.zero; node.name = NodeEditorUtilities.NodeDefaultName(typeof(AssetRootNode)); AssetDatabase.SaveAssets(); AssetDatabase.AddObjectToAsset(node, target); AssetDatabase.SaveAssets(); NodeEditorWindow.RepaintAll(); } }
public override void ButtonDraw(NodeEditorWindow window) { if (window.flag) { if (GUILayout.Button("接続")) { window.flag = false; Connect(window); } else if (GUILayout.Button("キャンセル")) { window.flag = false; Cancel(window); } } }
// Override open function public override void OnOpen() { // Init available nodes _availableNodes = new Dictionary <string, Type[]>(); _availableNodes["Model"] = NodeEditorWindow.GetDerivedTypes(typeof(PCGModelNode)); _availableNodes["Tileset"] = NodeEditorWindow.GetDerivedTypes(typeof(TilesetNode)); _availableNodes["Tile"] = NodeEditorWindow.GetDerivedTypes(typeof(TileNode)); _availableNodes["Noise"] = NodeEditorWindow.GetDerivedTypes(typeof(NoiseNode)); if (target != null) { _currentGraph = (PCGGraph)target; } window.titleContent = new GUIContent("PCGTool"); }
public override void ButtonDraw(NodeEditorWindow window) { if (window.flag) { if (GUILayout.Button("接続")) { window.flag = false; Connect(window); } else if (GUILayout.Button("キャンセル")) { window.flag = false; Cancel(window); } } else { if (GUILayout.Button("削除")) { if (EditorUtility.DisplayDialog("Warning", "このコンテンツを削除しますか?", "OK", "キャンセル")) { Remove(); } } else if (GUILayout.Button("リンク")) { window.flag = true; Link(window); } else if (GUILayout.Button("全てリンク解除")) { if (EditorUtility.DisplayDialog("Warning", "このコンテンツのリンクを解除しますか?", "OK", "キャンセル")) { UnLink(); } } else if (GUILayout.Button("その他のリンク解除")) { if (EditorUtility.DisplayDialog("Warning", "このコンテンツのリンクを解除しますか?", "OK", "キャンセル")) { next = null; } } } }
private void LoadFromTree() { var target = this.target; if (target == null) { return; } string path = AssetDatabase.GetAssetPath(target); path = System.IO.Path.GetDirectoryName(path).Replace('\\', '/'); string fileName = string.Format("{0}/{1}.bin", path, target.name); if (System.IO.Directory.Exists(fileName)) { IFormatter formatter = new BinaryFormatter(); System.IO.FileStream stream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Write); try { var nodes = formatter.Deserialize(stream) as List <Node>; if (nodes == null) { Debug.LogErrorFormat("[LoadFromTree] DeSerialeze Failed: {0}", fileName); } else { if (this.window != null) { this.window.Close(); } this.serializedObject = null; target.nodes = nodes; NodeEditorWindow.OnOpen(target.GetInstanceID(), 0); } } finally { stream.Close(); stream.Dispose(); } } else { Debug.LogErrorFormat("[LoadFromTree] not found file: {0}", fileName); } }
public static T GetEditor(K target, NodeEditorWindow window) { if (target == null) return null; T editor; if (!editors.TryGetValue(target, out editor)) { Type type = target.GetType(); Type editorType = GetEditorType(type); editor = Activator.CreateInstance(editorType) as T; editor.target = target; editor.serializedObject = new SerializedObject(target); editor.window = window; editor.OnCreate(); editors.Add(target, editor); } if (editor.target == null) editor.target = target; if (editor.window != window) editor.window = window; if (editor.serializedObject == null) editor.serializedObject = new SerializedObject(target); return editor; }
public static void CreateWindow(DialogSystemWindow board, Node node) { NodeEditorWindow window = GetWindow(typeof(NodeEditorWindow)) as NodeEditorWindow; window.board = board; window.target = node; window.editorInfo = new List <TransitionEditorInfo>(); foreach (Transition t in node.nextNodes) { TransitionEditorInfo te = new TransitionEditorInfo(); foreach (Logic l in t.logics) { te.logics.Add(new LogicEditor()); } window.editorInfo.Add(te); } window.Show(); }
public override void OnHeaderGUI() { if (!Initialised) { Target = target as ObjectSelector; Window = NodeEditorWindow.GetWindow(typeof(NodeEditorWindow)) as NodeEditorWindow; Window.SelectNode(Target, false); // Add runtime nodes to the dictionary for querying // We do this so it can be easily appended to the next dictionary's keys NodeEditorWindow.nodeTypes.ToList().ForEach(n => { // eliminate the system nodes if (n.Name != "ObjectSelector" && n.Name != "RuntimeGraphHolder") { RuntimeNodeTypes.Add(n.Name, n); } } ); // Add other runtime graphs to the dictionary which will also appear in the queries // these runtime graphs will be used as 'sub-graph' nodes string[] runtimeGraphGuids = AssetDatabase.FindAssets("t:RuntimeGraph", null); runtimeGraphGuids.ToList().ForEach(g => { var path = AssetDatabase.GUIDToAssetPath(g); var graph = AssetDatabase.LoadAssetAtPath <RuntimeGraph>(path); var name = path.Split('/').Last().Split('.').First(); if (name != Window.graph.name) { RuntimeGraphs.Add(name, graph); } }); Initialised = true; } // set the header field to editing int controlID = EditorGUIUtility.GetControlID(FocusType.Keyboard) + 1; EditorGUIUtility.keyboardControl = controlID; EditorGUIUtility.editingTextField = true; Input = EditorGUILayout.TextField(Input, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); }
public override void OnInspectorGUI() { serializedObject.Update(); if (GUILayout.Button("Edit", GUILayout.Height(40))) { NodeEditorWindow.Open(serializedObject.targetObject as XNode.NodeGraph); } GUILayout.Space(EditorGUIUtility.singleLineHeight); EditorGUILayout.LabelField("Title", EditorStyles.boldLabel); btGraph.title = EditorGUILayout.TextField(btGraph.title); EditorGUILayout.Space(); EditorGUILayout.LabelField("Description", EditorStyles.boldLabel); btGraph.description = EditorGUILayout.TextArea(btGraph.description, GUILayout.Height(70f)); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); if (GUILayout.Button("Edit graph")) { NodeEditorWindow.Open(serializedObject.targetObject as XNode.NodeGraph); } Draw_CreateVariablePanel(); DrawDefaultErrorPanel(); GUILayout.Space(EditorGUIUtility.singleLineHeight); GUILayout.Label("Raw data", "BoldLabel"); DrawDefaultInspector(); serializedObject.ApplyModifiedProperties(); }
public sealed override bool Calculate() { if (allInputsReady()) { module = CreateAndReadyModule(); NeedsUpdate = true; previewCalculation = null; Outputs[0].SetValue(module); NodeEditorWindow.NodeUpdated(this); return(true); } else { return(false); } }
public override void OnCreate() { base.OnCreate(); if (target.nodes.Where(a => a.GetType() == typeof(Blackboard)).FirstOrDefault() == null) { Blackboard node = (Blackboard)target.AddNode(typeof(Blackboard)); node.position = new Vector2(0, 0); if (node.name == null || node.name.Trim() == "") { node.name = NodeEditorUtilities.NodeDefaultName(typeof(Blackboard)); } //Normally we would check for autosave first, but since this should be standard in this graph we donot. //Also GetSettings() doesn't work when closing the EditorWindow of a previous graph until this graph is opened fully. AssetDatabase.SaveAssets(); NodeEditorWindow.RepaintAll(); AssetDatabase.AddObjectToAsset(node, target); (target as BlackBoardGraph).Blackboard = node; AssetDatabase.SaveAssets(); } }
public static void LoadGraph() { NodeGraph currentGraph = null; string graphPath = EditorUtility.OpenFilePanel("Load Graph", Application.dataPath + "Node Editor Unity/Database/", ""); int appPathLen = Application.dataPath.Length; string finalPath = graphPath.Substring(appPathLen - 6); currentGraph = (NodeGraph)AssetDatabase.LoadAssetAtPath(finalPath, typeof(NodeGraph)); if (currentGraph != null) { NodeEditorWindow curWindow = (NodeEditorWindow)EditorWindow.GetWindow <NodeEditorWindow> (); if (curWindow != null) { curWindow.currentGraph = currentGraph; } } else { EditorUtility.DisplayDialog("Node Message:", "Unable to load selected graph", "OK"); } }
private static void CacheCustomEditors() { editors = new Dictionary <Type, T>(); //Get all classes deriving from NodeEditor via reflection Type[] nodeEditors = NodeEditorWindow.GetDerivedTypes(typeof(T)); for (int i = 0; i < nodeEditors.Length; i++) { var attribs = nodeEditors[i].GetCustomAttributes(typeof(A), false); if (attribs == null || attribs.Length == 0) { continue; } if (nodeEditors[i].IsAbstract) { continue; } A attrib = attribs[0] as A; editors.Add(attrib.GetInspectedType(), Activator.CreateInstance(nodeEditors[i]) as T); } }
public override void AddContextMenuItems(GenericMenu menu) { // Actions if only one node is selected if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { XNode.Node node = Selection.activeObject as XNode.Node; menu.AddItem(new GUIContent("Move To Top"), false, () => NodeEditorWindow.current.MoveNodeToTop(node)); menu.AddItem(new GUIContent("Rename"), false, NodeEditorWindow.current.RenameSelectedNode); // Add Mark option for main model menu.AddItem(new GUIContent("Mark as main model"), false, () => ((PCGGraphEditor)NodeEditorWindow.current.graphEditor).MarkModelAsMain(_pcgModelNode)); } // Remove Duplicate menu.AddItem(new GUIContent("Remove"), false, NodeEditorWindow.current.RemoveSelectedNodes); // Custom sctions if only one node is selected if (Selection.objects.Length == 1 && Selection.activeObject is XNode.Node) { XNode.Node node = Selection.activeObject as XNode.Node; NodeEditorWindow.AddCustomContextMenuItems(menu, node); } }
public override void OnGUI() { base.OnGUI(); style.fontSize = 18; style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.white; GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(target.name, style, GUILayout.Height(20)); EditorGUILayout.LabelField((target as Quest).questName, style, GUILayout.Height(20)); if (GUILayout.Button("Open")) { string path = EditorUtility.OpenFilePanel("Open Quest", AssetDatabase.GetAssetPath(target).Replace(target.name + ".asset", ""), "asset").Replace(Application.dataPath, "Assets"); Quest quest = AssetDatabase.LoadAssetAtPath <Quest> (path); if (quest != null) { NodeEditorWindow.Open(quest); } } }
public override void OnGUI() { base.OnGUI(); style.fontSize = 18; style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.white; GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(target.name, style, GUILayout.Height(20)); EditorGUILayout.LabelField(((target as Conversation).defaultActor == null) ? "No actor assigned" : (target as Conversation).defaultActor.actorName, style, GUILayout.Height(20)); if (GUILayout.Button("Open")) { string path = EditorUtility.OpenFilePanel("Open Conversation", AssetDatabase.GetAssetPath(target).Replace(target.name + ".asset", ""), "asset").Replace(Application.dataPath, "Assets"); Conversation conversation = AssetDatabase.LoadAssetAtPath <Conversation> (path); if (conversation != null) { NodeEditorWindow.Open(conversation); } } }
public static void CreateNewNodeGraph(string _name) { NodeGraph graph = (NodeGraph)ScriptableObject.CreateInstance <NodeGraph> (); if (graph != null) { graph.graphName = _name; graph.InitGraph(); AssetDatabase.CreateAsset(graph, "Assets/Node Editor Unity/Database/" + _name + ".asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); NodeEditorWindow curWindow = (NodeEditorWindow)EditorWindow.GetWindow <NodeEditorWindow> (); if (curWindow != null) { curWindow.currentGraph = graph; } } else { EditorUtility.DisplayDialog("Node Message:", "Unable to create new graph!", "OK"); } }
// Override ContextMenu public override void AddContextMenuItems(GenericMenu menu) { Vector2 pos = NodeEditorWindow.current.WindowToGridPosition(Event.current.mousePosition); // Create menu on previously defined available nodes foreach (KeyValuePair <string, Type[]> item in _availableNodes) { foreach (Type t in item.Value) { menu.AddItem(new GUIContent($"{item.Key}/{t.Name}"), false, () => { CreateNode(t, pos); }); } } /*menu.AddItem(new GUIContent("Test Node"), false, () => { * CreateNode(typeof(TestNode), pos); * });*/ menu.AddSeparator(""); menu.AddItem(new GUIContent("Preferences"), false, () => NodeEditorWindow.OpenPreferences()); NodeEditorWindow.AddCustomContextMenuItems(menu, target); }
static void CreateEditor() { _editor = GetWindow<NodeEditorWindow> ("Node Editor"); _editor.minSize = new Vector2 (800, 600); _editor.NewNodeCanvas (); }
private static void CreateViews() { if(currentEditorWindow != null) { currentEditorWindow.currentPropertyView = new NodePropertyView(); currentEditorWindow.currentWorkView = new NodeWorkView(); currentEditorWindow.currentNodeTypeView = new NodeTypeView(); } else { currentEditorWindow = (NodeEditorWindow)EditorWindow.GetWindow<NodeEditorWindow>(); } }
static void CreateEditor() { editor = GetWindow<NodeEditorWindow> (); editor.minSize = new Vector2 (800, 600); }