Skip to content

Extensions

Valk edited this page Aug 27, 2025 · 9 revisions

Comprehensive Printing

The .PrintFormatted() extension method outputs all public properties and fields of any object, including nodes.

// Prints results with GD.Print()
node.PrintFormatted(); // Prints node without crashing the editor!!! Amazing!
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>();

Obtaining the Pixel Size of a Sprite

This gives you the dimensions of non-transparent pixels.

Vector2 size = sprite.GetPixelSize();

Node Extensions

T GetAutoload<T>(this Node node, string autoload) where T : Node
T GetSceneNode<T>(this Node node, string path) where T : Node
T GetNode<T>(this Node node, bool recursive = true) where T : Node

void AddToCurrentSceneDeferred(this Node node, Node child)
void AddToCurrentScene(this Node node, Node child)
void AddChildDeferred(this Node node, Node child)
void QueueFreeChildren(this Node parentNode)
void TraverseNodes(this Node node, Action<Node> code)

Node GetNodeInCurrentScene(this Node node, string path)
Node GetCurrentScene(this Node node)

List<Node> GetNodes(this Node node, Type type)
List<T> GetChildren<T>(this Node node, bool recursive = true) where T : Node

bool TryGetNode<T>(this Node node, out T foundNode, bool recursive = true) where T : Node
bool HasNode<T>(this Node node, bool recursive = true) where T : Node

Task WaitOneFrame(this Node parent)

Math Extensions

float Remap(this float value, float from1, float to1, float from2, float to2)

InputEventMouseButton Extensions

bool IsWheelUp(this InputEventMouseButton @event)
bool IsZoomIn(this InputEventMouseButton @event)
bool IsLeftClickPressed(this InputEventMouseButton @event)
bool IsRightClickJustReleased(this InputEventMouseButton @event)
// and so on...

Control Extensions

Control SetFontSize(this Control control, int fontSize)
Control SetMarginLeft(this Control control, int padding)
// and so on...

Camera2D Extensions

void SetPositionIgnoreSmoothing(this Camera2D camera, Vector2 position)

AnimationTree Extensions

void SetCondition(this AnimationTree tree, StringName path, bool value)
void SetBlendSpace1DPosition(this AnimationTree tree, StringName name, float value)
void SetParam(this AnimationTree tree, StringName path, Variant value)

Variant GetParam(this AnimationTree tree, StringName path)
bool GetCondition(this AnimationTree tree, StringName path)
AnimationNodeStateMachinePlayback GetStateMachine(this AnimationTree tree)

Note

Not all extensions on this page may be up to date. Only a select few highlighted extensions are shown here. For the full list click here.

Clone this wiki locally