Godot.DependencyInjection
0.2.2
See the version list below for details.
dotnet add package Godot.DependencyInjection --version 0.2.2
NuGet\Install-Package Godot.DependencyInjection -Version 0.2.2
<PackageReference Include="Godot.DependencyInjection" Version="0.2.2" />
paket add Godot.DependencyInjection --version 0.2.2
#r "nuget: Godot.DependencyInjection, 0.2.2"
// Install Godot.DependencyInjection as a Cake Addin #addin nuget:?package=Godot.DependencyInjection&version=0.2.2 // Install Godot.DependencyInjection as a Cake Tool #tool nuget:?package=Godot.DependencyInjection&version=0.2.2
Godot.DependencyInjection
Godot.DependencyInjection is a lightweight and easy-to-use dependency injection framework for the Godot game engine, specifically tailored for C#. It aims to help developers create more modular, testable, and maintainable game projects using the Godot engine.
Features
- Easy to set up and use
- Supports property, field, and method injection
- Provides member dependency injection for usage with resources
- Utilizes standard C# dependency injection abstractions
- Supports transient, scoped, and singleton lifetimes
Installation
You can install the package via NuGet or clone the repository and add a project reference to the solution created by Godot.
Usage
using Godot.DependencyInjection.Services.Input;
public partial class RegularNode : Node2D
{
[Inject]
public IInputService service1;
[Inject]
public IService Service { get; set; }
[Export]
[InjectMembers]
public CustomResource Resource { get; set; }
[Inject]
public void Inject(IService service)
{
// ***
}
}
Configuration
- Create a script for dependency manager:
public partial class DependencyInjectionNode : DependencyInjectionManagerNode { }
- Add the script to Project → Project Settings → Autoload.
- Create a node and script for dependency registration:
public partial class DependencyRegistrationNode : IServicesConfigurator { public override void ConfigureServices(IServiceCollection services) { services.AddGodotServices(); services.AddTransient<IService, Service>(); } }
- Add dependency registration node to scene
Remarks
Please note that this project is in its early stages of development and may require significant improvements. The framework is functional but may not be suitable for production use in its current state. Any feedback, suggestions, or contributions to improve the framework are highly appreciated.
Support
If you have any questions, issues, or suggestions, please create a new issue on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Godot.DependencyInjection.Core (>= 0.2.1)
- Godot.DependencyInjection.Services (>= 0.2.3)
- Godot.SourceGenerators (>= 4.0.2)
- GodotSharp (>= 4.0.2)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.