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
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
- GDScript
- C#
Key Differences
Naming conventions
Naming conventions
GDScript:
snake_case for methods and variablesC#: PascalCase for methods, properties, and public members; camelCase for private fieldsType system
Type system
C# is statically typed by default, while GDScript supports gradual typing:
Properties vs setters/getters
Properties vs setters/getters
C# uses properties instead of GDScript’s
set and get:Collections
Collections
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: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:.csproj file directly:
IDE Setup
- Visual Studio Code
- Visual Studio
- JetBrains Rider
Install the C# extension:
- Install C# Dev Kit
- Open your Godot project folder
- VS Code will detect the
.slnfile automatically
- Go to Editor → Editor Settings → Dotnet → Editor
- Set External Editor to Visual Studio Code
Common Patterns
Singleton Pattern
GameManager.cs
Resource Management
Debugging
Next Steps
GDScript
Learn Godot’s built-in scripting language
GDExtension
Create native C++ extensions
Visual Scripting
Explore node-based programming