2020-09-18 18:38:11 +10:00
|
|
|
|
using UnityEngine;
|
2020-08-18 17:38:09 +10:00
|
|
|
|
|
2020-10-23 01:48:18 +11:00
|
|
|
|
namespace Explorer
|
2020-08-18 17:38:09 +10:00
|
|
|
|
{
|
|
|
|
|
public static class UnityExtensions
|
|
|
|
|
{
|
|
|
|
|
public static string GetGameObjectPath(this Transform _transform)
|
|
|
|
|
{
|
|
|
|
|
return GetGameObjectPath(_transform, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetGameObjectPath(this Transform _transform, bool _includeThisName)
|
|
|
|
|
{
|
|
|
|
|
string path = _includeThisName ? ("/" + _transform.name) : "";
|
|
|
|
|
GameObject gameObject = _transform.gameObject;
|
|
|
|
|
while (gameObject.transform.parent != null)
|
|
|
|
|
{
|
|
|
|
|
gameObject = gameObject.transform.parent.gameObject;
|
|
|
|
|
path = "/" + gameObject.name + path;
|
|
|
|
|
}
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|