예제 #1
0
    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);
    }
예제 #2
0
    private void DrawMenuBar()
    {
        menuBar = new Rect(0, 0, position.width, menuBarHeight);

        GUILayout.BeginArea(menuBar, EditorStyles.toolbar);
        GUILayout.BeginHorizontal();

        if (GUILayout.Button(new GUIContent("Save"), EditorStyles.toolbarButton, GUILayout.Width(35)))
        {
            BTEditorManager.Save();
        }

        GUILayout.Space(5);
        if (GUILayout.Button(new GUIContent("Load"), EditorStyles.toolbarButton, GUILayout.Width(35)))
        {
            BTEditorManager.Load();
        }

        if (GUILayout.Button(new GUIContent("Clear"), EditorStyles.toolbarButton, GUILayout.Width(35)))
        {
            BTEditorManager.Clear();
        }

        if (GUILayout.Button(new GUIContent("Print"), EditorStyles.toolbarButton, GUILayout.Width(35)))
        {
            BTUtils.DumpTree(BTEditorManager.rootNode);
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }