Skip to main content

Overview

Godot supports C# as a scripting language through .NET integration. C# offers strong typing, powerful language features, and access to the entire .NET ecosystem.
C# support requires a special build of Godot with Mono/.NET enabled. Download the .NET version from the official Godot website.

Getting Started

Prerequisites

1

Download .NET Godot

Download the Godot .NET version from godotengine.org. The standard version doesn’t include C# support.
2

Install .NET SDK

Install the .NET SDK version 6.0 or later.Verify installation:
3

Create a C# project

In Godot, go to Project → Project Settings → Dotnet and click Create C# Solution.This generates the necessary .csproj and .sln files.

Your First C# Script

Player.cs
All C# classes that extend Godot nodes must be marked as partial. This is required for Godot’s source generators.

C# vs GDScript

Syntax Comparison

Key Differences

GDScript: snake_case for methods and variablesC#: PascalCase for methods, properties, and public members; camelCase for private fields
C# is statically typed by default, while GDScript supports gradual typing:
C# uses properties instead of GDScript’s set and get:
C# uses generic collections:

Exported Variables

Use the [Export] attribute to expose variables in the Inspector:

Signals in C#

Declaring Signals

Connecting Signals

Node References

Getting Nodes

OnReady Pattern

C# doesn’t have @onready, but you can use lazy initialization:

Using .NET Libraries

One major advantage of C# is access to the entire .NET ecosystem:
Be cautious with blocking async operations in Godot’s main thread. Use await properly or consider using Godot’s built-in threading.

Performance Considerations

C# is compiled

C# is compiled to native code, offering better performance for CPU-intensive tasks.

Startup overhead

C# has slightly longer initial startup time due to .NET runtime initialization.

Strong typing benefits

Static typing enables better compiler optimizations and catches errors at compile time.

Memory management

C# uses garbage collection, which can cause occasional frame hitches if not managed carefully.

Building and Exporting

Build Configuration

C# projects require compilation before running:
1

Build the project

In Godot, click Build in the top-right corner or press Alt+B.
2

Configure export templates

Download the .NET export templates for your target platform from the Godot download page.
3

Export settings

In Project → Export, ensure Embed .NET Runtime is enabled for standalone executables.

NuGet Packages

You can use NuGet packages in your Godot project:
Or edit the .csproj file directly:

IDE Setup

Install the C# extension:
  1. Install C# Dev Kit
  2. Open your Godot project folder
  3. VS Code will detect the .sln file automatically
External Editor Settings:
  • Go to Editor → Editor Settings → Dotnet → Editor
  • Set External Editor to Visual Studio Code

Common Patterns

Singleton Pattern

GameManager.cs

Resource Management

Debugging

Attach the Visual Studio or VS Code debugger to Godot for breakpoint debugging. Run Godot, then attach to the Godot process.

Next Steps

GDScript

Learn Godot’s built-in scripting language

GDExtension

Create native C++ extensions

Visual Scripting

Explore node-based programming