55 lines
862 B
C#
55 lines
862 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 )
|
|
{
|
|
var n = it.Name;
|
|
|
|
if ( RegexUtility.Matching( n, @"@\d+$" ) )
|
|
{
|
|
it = null;
|
|
}
|
|
else
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
|
|
}
|