// public void InternalGenerate(OutStruct outStruct) // { // internalGenerate(outStruct, outStruct.transform); // } private static void internalGenerate(OutStruct outStruct, Transform transform) { // 排除特殊目录 // if (outStruct.transform != transform && transform:GetComponent<TsGenerateHelper>() != null) // { // return; // } // 处理子目录 if (outStruct.transform != transform && transform.name.StartsWith("-")) { var childStruct = new OutStruct(); childStruct.parent = outStruct; childStruct.transform = transform; childStruct.level = outStruct.level + 1; outStruct.Childs.Add(childStruct); internalGenerate(childStruct, transform); return; } // 普通元素 if (transform.name.StartsWith("$")) { outStruct.Items.Add(transform); } // 遍历子元素 foreach (Transform child in transform) { internalGenerate(outStruct, child); } }
public static void Generate(GameObject root) { Root = root.transform; ExportConstStringBuilder.Length = 0; ConstStringBuilder.Length = 0; var outRoot = new OutStruct(); outRoot.transform = root.transform; internalGenerate(outRoot, root.transform); outRoot.export(); // // Debug.Log(ExportConstStringBuilder + "\n" + ConstStringBuilder); Debug.Log(ConstStringBuilder); // 复制到剪切板 TextEditor textEditor = new TextEditor(); textEditor.text = ConstStringBuilder.ToString(); textEditor.SelectAll(); textEditor.Copy(); }