unity3d 选择一个物体递归输出所有节点名字

using UnityEngine;
using UnityEditor;
using System.Collections;

public class PrintNode :  Editor{
    [MenuItem("PrintNode/Print")]
    public static void Print() {
        GameObject obj = Selection.activeGameObject;
        string str = "";
        Check(obj.transform, "", ref str);
        Debug.LogWarning(str);
    }

    static void Check(Transform tf, string gap, ref string str) {
        str += gap + tf.name + "\n";
        foreach (Transform item in tf) {
            Check(item, gap + "   ", ref str);
        }
    }
}

放在Editor下

你可能感兴趣的:(unity3d小技巧)