GodotGetNode 0.2.2

dotnet add package GodotGetNode --version 0.2.2
                    
NuGet\Install-Package GodotGetNode -Version 0.2.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GodotGetNode" Version="0.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GodotGetNode" Version="0.2.2" />
                    
Directory.Packages.props
<PackageReference Include="GodotGetNode" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GodotGetNode --version 0.2.2
                    
#r "nuget: GodotGetNode, 0.2.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GodotGetNode@0.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GodotGetNode&version=0.2.2
                    
Install as a Cake Addin
#tool nuget:?package=GodotGetNode&version=0.2.2
                    
Install as a Cake Tool

GodotGetNode

GitHub Issues

A production-ready Godot 4.x source generator to help you get your nodes!

Example

using Godot;

public partial class MyNode : Node2D {
	// Specify the name of the node
	[GetNode("Player")] CharacterBody2D player;

	// Custom syntax to get a node relative to another node!
	[GetNode(nameof(player), "Sprite")] Sprite2D sprite;
	// .. or a neater, but type unsafe syntax:
	[GetNode("{player}/Sprite")] Sprite2D sprite;
    
	public override void _Ready() {
		// No more GetNode<Sprite2D>("Player/Sprite") over here!
	}
}

Note

This repo might seem inactive, but this project works just fine.

I don't update this repo often as it doesn't need any updates, but I've been using it myself in my own Godot projects for about a year now as of the time I'm writing this.

If you do encounter any issues, please open up an issue or a PR on the repository!

Hide inlays in your IDE for the best experience

Compatibility

Actively tested for Godot 4.x

Version Godot 3.x Godot 4.x
0.1.x Likely
0.2.x Untested

All this project does is generate some GetNode<>()s on TreeEntered using types and names extracted from your code, so theoretically it should work on Godot 3.x

The .NET version and features the project is using might block use on 3.x though. If you use 3.x and this project doesn't work, please open up an issue and I will fix it right away!

Roadmap

  • Optionally allow specifying a variable name to the left of the node path string
    • Example: [GetNode(container, "PanelContainer/Label"] Label relativeToContainer;
    • -- There's no neat way of doing this, because of C# its required to use nameof(..)
  • A complete rewrite for cleanliness' sake.
    • Allow easier user debugging & Fix "Cannot access a disposed object" in some rare cases
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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.

Version Downloads Last Updated
0.2.2 194 6/12/2024
0.2.1 122 6/12/2024
0.2.0 122 6/12/2024
0.1.3 276 7/24/2023
0.1.2-alpha6 327 7/24/2023
0.1.2-alpha5 285 7/24/2023
0.1.2-alpha4 284 7/23/2023
0.1.2-alpha3 228 7/23/2023
0.1.2-alpha2 326 7/23/2023
0.1.2-alpha1 252 7/23/2023
0.1.1 198 7/23/2023
0.1.0 180 7/23/2023