Skip to content

Extensions

Valk edited this page Sep 19, 2024 · 10 revisions

Comprehensive Printing

The .PrintFormatted() extension method outputs all public properties and fields of any object, including nodes, providing a detailed snapshot of the object's state.

// Prints results with GD.Print()
node.PrintFormatted();
array.PrintFormatted();

// .ToFormattedString() may be desired if you don't want to use GD.Print()
Game.Log(node.ToFormattedString());
Game.Log(array.ToFormattedString());

Node Type Search

Recursively searches through the children of a node to find the first instance of a specified type.

entity.GetNode<Sprite2D>();

Retrieve Children by Type

Recursively gathers all nodes of a specified type from a given node.

List<Control> nothingButUINodes = mostlyUINodes.GetChildren<Control>();

QueueFree Children

Frees all child nodes of a given parent node.

node.QueueFreeChildren();

Clone this wiki locally