GodotOnReady

GodotOnReady is a C# source generator for Godot 3.x that provides `onready`-like functionality for C# scripts, eliminating the need for reflection. It offers attributes to load nodes/resources and execute methods during `_Ready`.

https://github.com/31/GodotOnReady

Preview Image

Preview

GodotOnReady: Streamlining C# Development in Godot 3.x

GodotOnReady simplifies C# scripting in Godot 3.x by introducing a source generator that mimics the convenience of GDScript's onready keyword. This tool eliminates the need for manual node retrieval and connection, resulting in cleaner and more maintainable code.

Key Features

  • [OnReadyGet] Attribute: Automatically loads a Node or Resource subclass into a field or property, and exports a property for configuration in the Godot editor.
  • [OnReady] Attribute: Executes any zero-argument method during the _Ready phase, allowing for initialization logic to be neatly organized.
  • [GenerateDataSelectorEnum] Attribute: Generates an enum where each value is strongly associated with custom data.

Usage and Benefits

GodotOnReady significantly reduces boilerplate code associated with node retrieval and initialization. By using the [OnReadyGet] and [OnReady] attributes, developers can focus on game logic rather than repetitive tasks. The tool also generates helpful error messages when node retrieval fails, improving the debugging experience.

Prerequisites

To use GodotOnReady, you'll need:

  • Godot 3.x with Mono
  • .NET SDK 6.0 or greater

Installation

Installation is as simple as adding the GodotOnReady NuGet package to your project. The package includes a C# class library with attributes and a source generator that automates code generation.

Resource Details

tool

31



3.x