Skip to content

Extensions

Valk edited this page Oct 4, 2024 · 2 revisions

Important

Not all extensions are documented here. For the full list click here.

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();