Skip to content

Cat Lips Source Generators

Valk edited this page Jan 29, 2026 · 1 revision

InputMap

From anywhere type InputActions.(...) to access both built-in and user defined actions defined in project.godot. For example InputActions.MoveLeft.

OnInstantiate

Add the following to any node script.

[OnInstantiate]
private void Init() // Optionally add params here
{
}

Then from anywhere do the following.

MyNode myNode = MyNode.Instantiate();
AddChild(myNode);

SceneTree

Add [SceneTree] attribute to the top of any class and you will be able to do some really cool things! Note that this only works for root scene nodes and the script must have the same name as the scene node and be right next to the scene node in the file system.

[SceneTree]
public partial class MyScene : Node2D 
{
    public override void _Ready() 
    {
        // You can access the node via '_' object.
        GD.Print(_.Node1.Node11.Node12.Node121);
        GD.Print(_.Node4.Node41.Node412);

        // You can also directly access nodes marked as having a unique name in the editor
        GD.Print(MyNodeWithUniqueName);
        GD.Print(_.Path.To.MyNodeWithUniqueName); // Long equivalent
    }
}

Thank you to Cat Lips for making https://github.com/Cat-Lips/GodotSharp.SourceGenerators

Clone this wiki locally