示例#1
0
        void BuildSettingTree()
        {
            var splitedSettingPathList = settings.Select(b => new { paths = b.filePath.Split('/'), settig = b }).ToList();
            var treeRootList           = new List <SettingTreeNode>();

            splitedSettingPathList.ForEach(pathSettings =>
            {
                var paths           = pathSettings.paths;
                var setting         = pathSettings.settig;
                var currentNodeList = treeRootList;
                for (var i = 0; i < paths.Length; i++)
                {
                    var path         = paths[i];
                    var nextNodeList = IsContainsPath(currentNodeList, path);
                    if (nextNodeList == null)
                    {
                        var newNode = new SettingTreeNode(path);
                        if (path == paths.Last())
                        {
                            newNode.setting = setting;
                        }
                        else
                        {
                            newNode.children = new List <SettingTreeNode>();
                        }
                        currentNodeList.Add(newNode);
                        nextNodeList = newNode.children;
                    }
                    currentNodeList = nextNodeList;
                }
            });
            settingTree = treeRootList;
        }
示例#2
0
 void ShowSettingNodeGUI(SettingTreeNode node)
 {
     GUI.contentColor = Color.white;
     GUILayout.BeginVertical("box");
     if (node.setting != null)
     {
         ShowSettingGUI(node.setting, node.path);
     }
     else if (node.open = GUILayout.Toggle(node.open, node.path + "/"))
     {
         node.children.Where(b => b.setting == null).ToList().ForEach(child => { ShowSettingNodeGUI(child); });
         GUILayout.Space(8);
         node.children.Where(b => b.setting != null).ToList().ForEach(child => { ShowSettingNodeGUI(child); });
     }
     GUILayout.EndVertical();
 }