mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-02 03:22:41 +08:00
Use StringBuilder for GetTransformPath
This commit is contained in:
@ -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>
|
||||||
|
Reference in New Issue
Block a user