Lavabird.SceneOnReady.Fody
1.0.0
dotnet add package Lavabird.SceneOnReady.Fody --version 1.0.0
NuGet\Install-Package Lavabird.SceneOnReady.Fody -Version 1.0.0
<PackageReference Include="Lavabird.SceneOnReady.Fody" Version="1.0.0" />
paket add Lavabird.SceneOnReady.Fody --version 1.0.0
#r "nuget: Lavabird.SceneOnReady.Fody, 1.0.0"
// Install Lavabird.SceneOnReady.Fody as a Cake Addin #addin nuget:?package=Lavabird.SceneOnReady.Fody&version=1.0.0 // Install Lavabird.SceneOnReady.Fody as a Cake Tool #tool nuget:?package=Lavabird.SceneOnReady.Fody&version=1.0.0
SceneOnReady
SceneOnReady is an IL weaver for Godot 3.x that adds onready
-style features to your C# scripts.
Features
- Apply
[OnReady]
attributes to class members to automatically fetchNode
references before your_Ready
method is is run. - Use either scene unique names (
%NodeName
), relative paths, or automatic paths based on the name of the field or property. - You can use your existing
_Ready
method as normal. Existing code will remain untouched.
Usage
SceneOnReady creates a relationship between class members and their related Node
object in a Godot scene. Simply attach an [OnReady]
attribute to a member and it will be fetched for you when your _Ready
method is run.
Instead of writing boiler plate code like this:
public class MyScene : Node
{
private Button _myButton;
public override void _Ready()
{
_myButton = GetNode<Button>("%MyButton");
}
}
You can instead write:
public class MyScene : Node
{
[OnReady]
private Button _myButton;
}
Additional code to fetch the node will be automatically injected at the start of your _Ready
method during the build process. You won't see any extra code in your editor.
The path of the node will be determined by the name of your field. Any leading underscore _
will be removed, and the first letter will be capitalised, and converted to a scene unique name. In the example above the member _myButton
will be resolved to a scene-unique Node
called %MyButton
.
Alternatively, you can manually specify a node-path using the Path
property of the attribute. This lets you use either a relative path, or a scene unique name which doesn't need to match the member name. For example:
public class MyScene : Node
{
[OnReady("Path/To/MyButton")]
private Button _myButton;
[OnReady("%CloseButton")]
private Button _quitButton;
}
You can continue to use your existing _Ready
methods as normal. Any members tagged with OnReady
mapping attributes will be ready to use when your _Ready
method is called.
If your class does not have a _Ready
method then one will be automatically injected for you at build time.
Installation
Simply add a reference to the SceneOnReady NuGet package to your project.
Method 1: Package Manager (Recommended)
Install the package in the project:
Install-Package Fody
Install-Package Lavabird.SceneOnReady.Fody
Method 2: Project Reference
Alternatively you can manually add a PackageReference
in your csproj
file for the NuGet package. When done your project should look something like:
<Project Sdk="Godot.NET.Sdk/3.3.0">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Lavabird.SceneOnReady.Fody" Version="1.0.0" />
</ItemGroup>
</Project>
FAQ
- How does this work?
SceneOnReady uses a process called IL weaving. Additional code will be injected into your game assembly during the build process. This new code is inserted at the head of each
_Ready
method where the class has aOnReady
attribute mapping. This code make calls to Godot'sGetNode
method to fetch the nodes - plus a little error checking to warn you of common pitfalls.
- Do I need to change my build process? No. An additional build step (MSBuild target) is generated by the weaving library (Fody) and automatically included when you install the SceneOnReady package. If you remove the library the build targets will be removed with it.
Dependencies
- Godot 3.5 (Mono) LTS
- Fody >= 6.8.0
License
SceneOnReady licensed under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
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 |
---|---|---|
1.0.0 | 166 | 9/11/2023 |