Use StringBuilder for GetTransformPath

This commit is contained in:
Sinai 2021-05-16 21:45:38 +10:00
parent 8c5e7678a6
commit f4e473f8e6

View File

@ -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>