public void ShowProperty(int nodeId) { if (mCurrent == null) { return; } Node node = mCurrent.GetNodeByID(nodeId); NodePropertyLayoutHelper.Show(node); }
protected virtual void SerializeConnect(XmlElement root, Connection connect, NodeFlow flow) { XmlElement connectElm = root.OwnerDocument.CreateElement("connection"); root.AppendChild(connectElm); connectElm.SetAttribute("name", connect.name); connectElm.SetAttribute("from_node", connect.outId.ToString()); Node node = flow.GetNodeByID(connect.outId); connectElm.SetAttribute("from_output", node.GetNextNodeNameByIdx(connect.outIdx)); connectElm.SetAttribute("to_node", connect.inId.ToString()); node = flow.GetNodeByID(connect.inId); connectElm.SetAttribute("to_input", node.GetPreNodeNameByIdx(connect.inIndex)); }
protected virtual void ParseConnection(XmlElement elm, NodeFlow flow) { string connectName = elm.GetAttribute("name"); ConnectionDef def = editor.GetConnectionDef(connectName); if (def == null) { UnityEngine.Debug.LogError("can not prase connect:" + connectName); return; } int fromNode = int.Parse(elm.GetAttribute("from_node")); string fromOutput = elm.GetAttribute("from_output"); Node outNode = flow.GetNodeByID(fromNode); int fromOutputIdx = outNode.GetNextNodeIdxByName(fromOutput); NextNode nextNode = outNode.nextNodeList[fromOutputIdx]; int toNode = int.Parse(elm.GetAttribute("to_node")); string toInput = elm.GetAttribute("to_input"); Node inNode = flow.GetNodeByID(toNode); int toInputIdx = inNode.GetPreNodeIdxByName(toInput); PreNode preNode = inNode.preNodeList[toInputIdx]; flow.BindConnection(nextNode, preNode, def); }
//default node renderer public static void NodeWindow(int id) { if (curFlow == null) { return; } Node node = curFlow.GetNodeByID(id); if (node == null) { return; } GUI.DragWindow(new Rect(0, 0, node.rect.width, 20)); //in { for (int i = 0; i < node.preNodeList.Count; ++i) { PreNode pre = node.preNodeList[i]; int height = 30 + pre.inIdx * 30; Rect rect = new Rect(20, height, 60, 30); GUI.Label(rect, pre.desc); } } //out { for (int i = 0; i < node.nextNodeList.Count; ++i) { NextNode next = node.nextNodeList[i]; int height = 30 + next.outIdx * 30; Rect rect = new Rect(node.rect.width - 60, height, 60, 30); GUI.Label(rect, next.desc); } } //seocket cell { for (int i = 0; i < node.preNodeList.Count; ++i) { PreNode pre = node.preNodeList[i]; Color c = pre.connectDef != null ? pre.connectDef.color : Color.white; GUI.color = c; GUI.Box(pre.rect, ""); } for (int i = 0; i < node.nextNodeList.Count; ++i) { NextNode next = node.nextNodeList[i]; Color c = next.connectDef != null ? next.connectDef.color : Color.white; GUI.color = c; GUI.Box(next.rect, ""); } GUI.color = Color.white; } //delete button if (NodeFlowEditorWindow.instance.GetSelectedNodeId() == id) { if (GUI.Button(new Rect(node.rect.width / 2 - 10, node.rect.height - 20, 20, 20), "X")) { //del node OperCmdInfo cmdInfo = new OperCmdInfo(); cmdInfo.cmd = OperCmd.REMOVE_NODE; cmdInfo.param = id; NodeFlowEditorWindow.instance.AddCmd(cmdInfo); } } }