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

来源:互联网 发布:京东类似淘宝联盟 编辑:程序博客网 时间:2024/05/11 20:34
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下

0 0
原创粉丝点击