private static string TreeSelectJson(List <TreeSelectModel> data, string parentId, string blank) { StringBuilder sb = new StringBuilder(); var ChildNodeList = data.FindAll(t => t.parentId == parentId || t.parentId == ""); if (ChildNodeList.Count < 1 && parentId == "0") { ChildNodeList = data; } var tabline = ""; if (parentId != "0" && parentId != "") { ChildNodeList = ChildNodeList.FindAll(t => t.parentId == parentId); tabline = " "; } if (ChildNodeList.Count > 0) { tabline = tabline + blank; } foreach (TreeSelectModel entity in ChildNodeList) { entity.text = tabline + entity.text; string strJson = entity.ToJson(); sb.Append(strJson); sb.Append(TreeSelectJson(data, entity.id, tabline)); } return(sb.ToString().Replace("}{", "},{")); }
public SetNode(SetDef.Block block, string baseFolder, Node parentNode) { Title = block.Title; Parent = parentNode; for (int i = 0; i < MusicNodes.Length; i++) { MusicNodes[i] = null; if (string.IsNullOrEmpty(block.File[i])) { continue; } try { var fullPath = Path.Combine(baseFolder, block.File[i]); if (!File.Exists(fullPath)) { continue; } var musicNode = new MusicNode(fullPath, this); ChildNodeList.Add(musicNode); Difficulty[i].Label = block.Label[i]; Difficulty[i].Level = (float)musicNode.Score.Difficulty; MusicNodes[i] = musicNode; if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(MusicNodes[i].Title)) { Title = MusicNodes[i].Title; } } catch (System.Exception ex) { Debug.LogError("fail to load. Exception:" + ex); } } for (var i = 0; i < ThumbnailNames.Length; i++) { var fullPath = Path.Combine(baseFolder, ThumbnailNames[i]); if (File.Exists(fullPath)) { PreviewImagePath = fullPath; break; } } }