mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-17 14:37:49 +08:00
Use StringBuilder for GetTransformPath
This commit is contained in:
parent
8c5e7678a6
commit
f4e473f8e6
@ -56,17 +56,18 @@ namespace UnityExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetTransformPath(this Transform transform, bool includeSelf = false)
|
public static string GetTransformPath(this Transform transform, bool includeSelf = false)
|
||||||
{
|
{
|
||||||
string path = includeSelf
|
var sb = new StringBuilder();
|
||||||
? transform.transform.name
|
if (includeSelf)
|
||||||
: "";
|
sb.Append(transform.name);
|
||||||
|
|
||||||
while (transform.parent)
|
while (transform.parent)
|
||||||
{
|
{
|
||||||
transform = transform.parent;
|
transform = transform.parent;
|
||||||
path = $"{transform.name}/{path}";
|
sb.Insert(0, '/');
|
||||||
|
sb.Insert(0, transform.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user