GodotResourceGenerator 0.2.2

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package GodotResourceGenerator --version 0.2.2
                    
NuGet\Install-Package GodotResourceGenerator -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="GodotResourceGenerator" Version="0.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GodotResourceGenerator" Version="0.2.2" />
                    
Directory.Packages.props
<PackageReference Include="GodotResourceGenerator" />
                    
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 GodotResourceGenerator --version 0.2.2
                    
#r "nuget: GodotResourceGenerator, 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 GodotResourceGenerator@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=GodotResourceGenerator&version=0.2.2
                    
Install as a Cake Addin
#tool nuget:?package=GodotResourceGenerator&version=0.2.2
                    
Install as a Cake Tool

Godot Resource Generator

NuGet NuGet (pre-release) License: MIT Build

Godot Resource Generator is a .NET source generator that creates Godot Resource classes from existing C# model types.

It is designed for projects that keep regular domain models separate from Godot editor-facing resources, while still wanting strongly typed exported properties and simple model-to-resource mapping.

Prerequisites

  • .NET SDK 8.0 or later for consuming projects.
  • A Godot C# project that references Godot 4 C# assemblies.

Installation

Install the package:

dotnet add package GodotResourceGenerator --version 0.1.0

Mark it as a build-only dependency in your .csproj file:

<PackageReference Include="GodotResourceGenerator"
                  Version="0.1.0"
                  PrivateAssets="all"
                  ExcludeAssets="runtime" />

Basic Usage

Create a regular model type:

public sealed class User
{
    public string Name { get; set; } = "";
    public int Level { get; set; }
    public Godot.Vector3 SpawnPosition { get; set; }
}

Add a partial resource class and point it at the model:

using GodotResourceGenerator;

[GodotResource(typeof(User))]
internal partial class UserResource;

The generator emits a Godot resource:

[global::Godot.GlobalClass]
internal partial class UserResource : global::Godot.Resource
{
    [global::Godot.Export]
    public string Name { get; set; }

    [global::Godot.Export]
    public int Level { get; set; }

    [global::Godot.Export]
    public global::Godot.Vector3 SpawnPosition { get; set; }

    public static UserResource FromModel(User model) { ... }

    public void CopyFrom(User model) { ... }
}

Custom Resource Bases

Generated resources derive from Godot.Resource by default. To use your own base resource type, either pass it as the second attribute argument:

public abstract class GameResource : Godot.Resource
{
}

[GodotResource(typeof(User), typeof(GameResource))]
internal partial class UserResource;

Or declare the base on the partial resource class:

[GodotResource(typeof(User))]
internal partial class UserResource : GameResource;

The custom base type must derive from Godot.Resource. If both forms are used, they must name the same base type.

Supported Types

The generator supports public readable instance properties whose types can be exported by Godot:

  • C# primitive Variant-compatible types and string.
  • Enums.
  • Nullable value types when the underlying type is supported, such as int? or MyEnum?.
  • Godot built-in structs such as Vector2, Vector3, and Color.
  • Types deriving from Godot.GodotObject.
  • Godot.Collections.Array, Array<T>, Dictionary, and Dictionary<TKey, TValue> when generic arguments are supported.
  • C# arrays.
  • CLR sequences such as List<T> and IReadOnlyList<T>, emitted as Godot.Collections.Array<T>.
  • Nested model classes or structs annotated with [GodotResource], emitted as their generated resource type.
  • Derived model properties can use the nearest mapped base model resource.

Unsupported property types produce diagnostics and suppress generation for the affected resource.

Mapping Helpers

Generated resources include:

  • static FromModel(TModel model) to create a new resource.
  • CopyFrom(TModel model) to update an existing resource.

Nested annotated models are mapped recursively. CLR sequences are copied into new Godot arrays.

License

Licensed under the MIT License.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • 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