public void Export(BaseNode rootNode, string configName) { string configPath = BTUtils.GetGenPath() + configName + ".json"; string fullConfigPath = BTUtils.GetGenPath() + configName + "_full.json"; string nodeMapPath = BTUtils.GetGenPath() + configName + "_node_map.json"; Dictionary <string, BaseNodeData> baseNodeDataDict = new Dictionary <string, BaseNodeData>(); Dictionary <string, MergePyData> dataDict = new Dictionary <string, MergePyData>(); BTUtils.DumpTree(rootNode, (BaseNode node) => { BaseNodeData nodeData = NodeDataManager.Get(node); if (nodeData != null) { nodeData.Serialize(node); dataDict[node.name] = new MergePyData(node); baseNodeDataDict[node.name] = nodeData; } }); BTUtils.SaveJsonToFile <Dictionary <string, MergePyData> >(dataDict, configPath); BaseNodeData rootNodeData = NodeDataManager.Get(rootNode); BTUtils.SaveJsonToFile <BaseNodeData>(rootNodeData, fullConfigPath); BTUtils.SaveJsonToFile <Dictionary <string, BaseNodeData> >(baseNodeDataDict, nodeMapPath); }
public static void SaveCurrentConnection() { if (selectedConnection != null) { ConnectionData data = NodeDataManager.Get(selectedConnection); if (data != null) { data.Serialize(selectedConnection); } } }
public virtual void Serialize(BaseNode node) { base.SetId(node); this.name = node.name; this.x = (int)node.rect.x; this.y = (int)node.rect.y; this.outPoint = NodeDataManager.Get(node.outPoint); this.inPoint = NodeDataManager.Get(node.inPoint); this.properties = node.properties; }
public static void SaveCurrentNode() { if (selectedNode != null) { BaseNodeData nodeData = NodeDataManager.Get(selectedNode); if (nodeData != null) { nodeData.Serialize(selectedNode); } } }
private void RemoveTreeConnection() { //out's child remove in this.outPoint.node.childs.Remove(this.inPoint.node); //out's child remove in BaseNodeData outNodeData = NodeDataManager.Get(this.outPoint.node); BaseNodeData inNodeData = NodeDataManager.Get(this.inPoint.node); NodeDataManager.Remove(this, outNodeData); }
public virtual void Serialize(Connection connection) { base.SetId(connection); //Debug.Log(">connection data " + this.id); this.connectId = connection.connectId; this.slotList.Clear(); foreach (SlotData slot in connection.slotList) { this.slotList.Add(slot); } this.outPoint = NodeDataManager.Get(connection.outPoint); this.inPoint = NodeDataManager.Get(connection.inPoint); }
public virtual void DeSerialize(ref BaseNode node) { BaseNodeData oldData = NodeDataManager.Get(node); //this可能不是node对应的那份数据 oldData.Sync(this); node.id = this.id; node.name = this.name; node.rect.x = this.x; node.rect.y = this.y; //node.outPoint = BTEditorManager.GetObject<ConnectionPoint>(this.outPoint); //node.inPoint = BTEditorManager.GetObject<ConnectionPoint>(this.inPoint); node.properties = this.properties; }
private void BuildTreeConnection() { //out's child is in this.outPoint.node.childs.Add(this.inPoint.node); //out's child is in BaseNodeData outNodeData = NodeDataManager.Get(this.outPoint.node); BaseNodeData inNodeData = NodeDataManager.Get(this.inPoint.node); ConnectionData connectionData = NodeDataManager.CreateConnectionData(this); connectionData.targetNodeId = inNodeData.id; outNodeData.connectionList.Add(connectionData); }
private void DrawSlots() { var connection = BTEditorManager.selectedConnection; GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.Label("Name", GUILayout.MaxWidth(80)); connection.connectId = EditorGUILayout.TextArea(connection.connectId, GUILayout.MaxHeight(25)); GUILayout.EndHorizontal(); GUILayout.Label("Slots"); for (int i = 0; i < connection.slotList.Count; i++) { GUILayout.BeginHorizontal(""); connection.slotList[i].out_slot = EditorGUILayout.TextArea(connection.slotList[i].out_slot, GUILayout.MaxHeight(25)); connection.slotList[i].in_slot = EditorGUILayout.TextArea(connection.slotList[i].in_slot, GUILayout.MaxHeight(25)); if (GUILayout.Button("-", GUILayout.MaxWidth(50))) { _slots_remove_list.Add(connection.slotList[i]); } GUILayout.EndHorizontal(); } for (int i = 0; i < _slots_remove_list.Count; i++) { SlotData remove_key = _slots_remove_list[i]; connection.slotList.Remove(remove_key); GUI.changed = true; } _slots_remove_list.Clear(); if (GUILayout.Button("+", GUILayout.MaxWidth(50))) { var connectionData = NodeDataManager.Get(connection); SlotData slotData = new SlotData(); slotData.SetupConnect(connectionData); connection.slotList.Add(slotData); GUI.changed = true; } }
public MergePyData(BaseNode node) { this.connections = new List <Dictionary <string, string> >(); if (node.type == NodeType.ExcelNode) { ExcelNodeData data = (ExcelNodeData)NodeDataManager.Get(node); if (data != null) { this.name = data.name; this.file = data.file; this.is_collect_info = false; if (data.properties.ContainsKey("is_collect_info") && data.properties["is_collect_info"][0] == "True") { this.is_collect_info = true; } if (data.connectionList != null) { foreach (ConnectionData connection in data.connectionList) { foreach (SlotData slotData in connection.slotList) { Dictionary <string, string> slotDic = new Dictionary <string, string>() { { "in_slot", slotData.in_slot }, { "node", slotData.node }, { "out_slot", slotData.out_slot } }; connections.Add(slotDic); } } } } } }