# GodotOnReady **GodotOnReady** is a [C# Source Generator] for Godot 3.x that adds convenient `onready`-like features to your C# scripts in Godot Mono without any reflection. * [`[OnReadyGet]`](#onreadyget) - Load a `Node` or `Resource` subclass into a field or property. Automatically exports a property so you can use the Godot editor to configure the path it loads. * [`[OnReady]`](#OnReady) - Execute any 0-argument method during `_Ready`. Bonus feature: * [`[GenerateDataSelectorEnum]`](docs/GenerateDataSelectorEnum.md) - Generate an enum where each value is strongly associated with custom data. ## Prerequisites * Godot 3.x, Mono version (4.0+ not supported due to C# source generator conflicts: [GodotOnReady#49](https://github.com/31/GodotOnReady/issues/49)) * .NET SDK 6.0 or greater * Set Godot to use the `dotnet CLI` Build Tool
Screenshot showing this editor setting (click me!) ![](docs/img/EditorSettings-BuildTool-cli.png)
## Project setup Just add the [`GodotOnReady`](https://www.nuget.org/packages/GodotOnReady) NuGet package to your project! Your Godot project's `.csproj` file should look like this when you're done: ```xml net472 ``` `GodotOnReady` includes two subpackages: a C# class library with a few attributes, and a source generator that detects when you use those attributes and generates code behind the scenes. After clicking Build one time to set up the package, you may need to restart your IDE to let the generator load and provide autocomplete/intellisense information. > For advanced alternatives like building from source or avoiding a reference to `GodotOnReady.Attributes`, see [/docs/advanced-setup.md](/docs/advanced-setup.md). ## Usage ### `[OnReadyGet]` Instead of writing this repetitive code: ```cs public class MyControl : Control { [Export] public NodePath ButtonPath { get; set; } private Button _button; public override void _Ready() { _button = GetNode