readme
This commit is contained in:
30
BITKit/Scripts/Extensions/Node.cs
Normal file
30
BITKit/Scripts/Extensions/Node.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Godot;
|
||||
|
||||
namespace BITKit;
|
||||
/// <summary>
|
||||
/// 为Godot.Node提供数学工具
|
||||
/// </summary>
|
||||
public static partial class MathNode
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取Node下所有的子Node节点
|
||||
/// </summary>
|
||||
/// <param name="self">Root Node</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Node> GetAllNode(Node self)
|
||||
{
|
||||
List<Node> nodes = new() { self };
|
||||
For(self);
|
||||
void For(Node node)
|
||||
{
|
||||
foreach (var x in node.GetChildren())
|
||||
{
|
||||
For(x);
|
||||
nodes.Add(x);
|
||||
}
|
||||
}
|
||||
return nodes.Distinct();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user