GodotComponentTest/entities/Flower.cs

33 lines
769 B
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
using Godot;
using Godot.Collections;
namespace GodotComponentTest.entities;
public class Flower : Entity
{
public override void _Ready()
{
Array<Node> children = new Array<Node>();
GetAllChildren(this, ref children);
foreach (Node child in children)
{
if (child is ClickableComponent)
{
GD.Print("Found Clickable Component!");
}
}
}
void GetAllChildren(Node childNode, ref Array<Node> childList)
{
var children = childNode.GetChildren();
foreach (Node child in children)
{
childList.Add(child);
GetAllChildren(child, ref childList);
}
}
}