33 lines
795 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class CEditor : Editor
{
[MenuItem("GameObject/CopyHierarchyPath", false, 11)]
public static void CopyHierarchy()
{
GameObject go = Selection.activeGameObject;
string path = go.GetRPath();
path = path.Replace("Canvas (Environment)/", "");
GUIUtility.systemCopyBuffer = path;
}
}
public static class Ex
{
public static string GetRPath(this GameObject go)
{
GameObject current = go;
string path = current.name;
while (null != current.transform.parent)
{
current = current.transform.parent.gameObject;
path = current.name + "/" + path;
}
return path;
}
}