-
Notifications
You must be signed in to change notification settings - Fork 8
Source Generators
Valk edited this page Oct 18, 2024
·
3 revisions
For full explanations and a complete list of all of Cat Lips source generators, visit https://github.com/Cat-Lips/GodotSharp.SourceGenerators
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);
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
}
}
From anywhere type InputActions.(...)
to access both built-in and user defined actions defined in project.godot
. For example InputActions.MoveLeft
.