Nenofite.GodotGrabber
1.2.7
dotnet add package Nenofite.GodotGrabber --version 1.2.7
NuGet\Install-Package Nenofite.GodotGrabber -Version 1.2.7
<PackageReference Include="Nenofite.GodotGrabber" Version="1.2.7" />
paket add Nenofite.GodotGrabber --version 1.2.7
#r "nuget: Nenofite.GodotGrabber, 1.2.7"
// Install Nenofite.GodotGrabber as a Cake Addin
#addin nuget:?package=Nenofite.GodotGrabber&version=1.2.7
// Install Nenofite.GodotGrabber as a Cake Tool
#tool nuget:?package=Nenofite.GodotGrabber&version=1.2.7
Godot Grabber
Godot Grabber is a source generator for Godot C# scripts. It reduces boilerplate when getting nodes within a script:
partial class MyNode : Node
{
// This will get a scene-unique node named "%CharacterSprite"
[Grab]
Sprite2D CharacterSprite;
// This will get a node at path "Other/Sprite"
[Grab("Other/Sprite")]
Sprite2D EnemySprite;
public override void _Ready()
{
// Call within _Ready() to actually get the above nodes
GrabNodes();
}
}
The generator makes a private method GrabNodes
to set the values of each field marked with [Grab]
. Because it's generated at compile time, no runtime reflection is performed. This keeps things lightweight.
Scene unique nodes
The default and recommended behavior is to use scene unique nodes that exactly match the name of the C# field. These nodes are marked with a %
in the Godot editor.
Because the nodes are scene unique, you can move them within the hierarchy of the scene without changing the binding in C#.
Custom paths
If you'd like to specify a custom path instead, pass a path to the attribute:
[Grab("Other/Sprite")]
Sprite2D EnemySprite;
The path string is passed directly to Node.GetNode()
, so it supports the usual NodePath syntax.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.