项目需要,所以写了一个
具体的大家请根据源码做出修改
这里指出关键的地方
节点结构
public struct TreeNode
{
public string Name;
public string Path;
public List<TreeNode> TreeBranch;
public List<string> UIComponentTypeList;
}
/// <summary>
/// 扫描标记的子物体
/// </summary>
/// <param name="trans"></param>
/// <param name="dict">存放所有子物体</param>
static void ScanChildUI(Transform trans,ref List<TreeNode> tree)
{
for (int i = 0; i < trans.childCount; i++)
{
Transform childtrans = trans.transform.GetChild(i);
//如果未标记ui并且后续不再有子物体
if (childtrans.name.Split('_').First() != "ui" && childtrans.childCount == 0)