ソースコード
using UnityEngine; public static class GameObjectExt { public static string GetHierarchyPath( this GameObject gameObject ) { var path = gameObject.name; var parent = gameObject.transform.parent; while ( parent != null ) { path = parent.name + "/" + path; parent = parent.parent; } return path; } }
使用例
using UnityEngine; public class Test : MonoBehaviour { private void Awake() { Debug.Log( gameObject.GetHierarchyPath() ); } }