rj-action-library/Runtime/Godot/HierarchyName.cs

46 lines
694 B
C#

using Godot;
using System.Text;
using System.Collections.Generic;
namespace Rokojori
{
public class HierarchyName
{
public static string Of( Node node, string seperator = "/" )
{
if ( node == null )
{
return "null";
}
var list = new List<string>();
var it = node;
while ( it != null )
{
list.Add( it.Name );
it = it.GetParent();
}
list.Reverse();
var sb = new StringBuilder();
for ( int i = 0; i < list.Count; i++)
{
if ( i != 0 )
{
sb.Append( seperator );
}
sb.Append( list[ i ] );
}
return sb.ToString();
}
}
}