mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 01:48:07 +08:00
Use StringBuilder for GetTransformPath
This commit is contained in:
1 parent
8c5e7678a6
commit
f4e473f8e6
1 file changed
+6
-5
@@ -56,17 +56,18 @@ namespace UnityExplorer
|
||||
/// </summary>
|
||||
public static string GetTransformPath(this Transform transform, bool includeSelf = false)
|
||||
{
|
||||
string path = includeSelf
|
||||
? transform.transform.name
|
||||
: "";
|
||||
var sb = new StringBuilder();
|
||||
if (includeSelf)
|
||||
sb.Append(transform.name);
|
||||
|
||||
while (transform.parent)
|
||||
{
|
||||
transform = transform.parent;
|
||||
path = $"{transform.name}/{path}";
|
||||
sb.Insert(0, '/');
|
||||
sb.Insert(0, transform.name);
|
||||
}
|
||||
|
||||
return path;
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user