Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

Constants Generator C#

An asset by Michael-Domanek
The page banner background of a mountain and forest
Constants Generator C# hero image

Quick Information

0 ratings
Constants Generator C# icon image
Michael-Domanek
Constants Generator C#

The plugin automatically extracts input actions, collision layers, and group names from project.godot and generates strongly-typed C# constants.

Supported Engine Version
4.0
Version String
1.0.3
License Version
MIT
Support Level
community
Modified Date
10 months ago
Git URL
Issue URL

Constants Generator Plugin for Godot

The Godot plugin automatically extracts input actions, collision layers, and group names from project.godot and generates strongly-typed C# constants.

Features

  • Parses project.godot to extract:
    • Input actions
    • Collision layers
    • Group names
  • Automatically generates files on project settings change
  • Generates static StringName constants or uint for collision layers
  • Automatically infers root namespace from .csproj
  • Customizable class names and location
  • Optional disabling of specific categories (actions, groups, layers)
  • Only updates changed files to avoid unnecessary recompilation

Installation

  1. Install plugin in addons folder
  2. Enable the plugin:
  • Project > Project Settings > Plugins
  • Build the C# project if necessary
  • Enable Constants-Generator in Project > Project Settings > Plugins

Requirements

  • Godot Mono 4.x
  • C#/.NET project enabled

Editor Settings

You can configure the plugin under:

Editor > Editor Settings > Constants-Generator

Enable Advanced Settings in the top right and scroll down to the bottom to find the plugin settings.

Key Description
project_name Custom project name override (optional)
namespace_overwrite Namespace to use in generated files (optional)
path_to_scripts Output directory path for generated .cs files (relative to project root)
actions_name Class name for generated input actions
layers_name Class name for generated collision layers
groups_name Class name for generated node groups
generate_actions Whether to generate the actions file
generate_layers Whether to generate the layers file
generate_groups Whether to generate the groups file

Files are only written when content has changed to avoid unnecessary reimports and build noise.

Example

Each file will contain a static class like the following:

using Godot;

namespace MyGame.Constants;

public static class Actions {
    public static readonly StringName Jump = "Jump";
    public static readonly StringName Shoot = "Shoot";
}

And you can use these constants in your scripts like this:

public override void _Input(InputEvent @event) {
    if (@event.IsActionPressed(Actions.Attack)) {
        // attack
    }
    if (@event.IsActionPressed(Actions.Jump)) {
        // jump
    }
}

License

MIT License

The plugin automatically extracts input actions, collision layers, and group names from project.godot and generates strongly-typed C# constants.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
Constants Generator C# icon image
Michael-Domanek
Constants Generator C#

The plugin automatically extracts input actions, collision layers, and group names from project.godot and generates strongly-typed C# constants.

Supported Engine Version
4.0
Version String
1.0.3
License Version
MIT
Support Level
community
Modified Date
10 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers