| using UnityEngine; | 
| using UnityEditor; | 
|   | 
| public class SampleEditorTool : ScriptableObject | 
| { | 
|   | 
|     [MenuItem("程序/小工具/打印所选对象Hierarchy地址")] | 
|     static void PrintHierarchyPath() | 
|     { | 
|         Debug.Log(PrintHierarchyPath(Selection.activeTransform)); | 
|     } | 
|   | 
|     public static string PrintHierarchyPath(Transform t) | 
|     { | 
|         System.Text.StringBuilder _name = new System.Text.StringBuilder(); | 
|   | 
|         if (t != null) | 
|         { | 
|             _name.Append(t.name); | 
|   | 
|             while (t.parent != null) | 
|             { | 
|                 if (t.parent.parent == null) | 
|                 { | 
|                     break; | 
|                 } | 
|                 _name.Insert(0, t.parent.name + "/"); | 
|                 t = t.parent; | 
|             } | 
|         } | 
|   | 
|         string _str = _name.ToString(); | 
|         _name = null; | 
|   | 
|         return _str; | 
|     } | 
| } |