Mirage.Godot

April 20, 2026 ยท View on GitHub

High level c# Networking for Godot based on popular open source Unity networking solutions Mirror and Mirage

Video Demo of example project: https://youtu.be/Ty55PZWtsJI

Features

  • Multiple Transport support. Use built in UDP transport or add your own to work with other services
  • RPC calls via attributes
  • SyncVar to sync fields without any extra code
  • Automatic serialization
  • Spawn Objects other the network
  • Object ownership. Allows the client to have control over object and automatically sync changes to other clients

Docs

Documentation for the unity version of Mirage can be found at https://miragenet.github.io/Mirage/. Most of the same concepts will apply to the Godot version.

Install

Requirements:

The paths below assumes that your new Godot game will share the same parent directory with Mirage.Core. Please adjust the paths as needed.
Open a command prompt at the shared parent directory.

  1. Clone repo git clone git@github.com:James-Frowen/Mirage.Godot.git
  2. Change directory into your Godot project. cd godot-game-dir
  3. Copy Mirage.Godot/src/Mirage.Godot/Scripts into your godot project with the following command:
    cp -r ../Mirage.Godot/src/Mirage.Godot/Scripts ./Mirage.Godot/Scripts
  4. Include the following changes to your Godot project's main .csproj:
  <PropertyGroup>
   <TargetFramework>net8.0</TargetFramework>
   <EnableDynamicLoading>true</EnableDynamicLoading>
   <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
 </PropertyGroup>
 <ItemGroup>
   <ProjectReference Include="..\Mirage.Godot\src\Mirage.Core\Mirage.Logging\Mirage.Logging.csproj" />
   <ProjectReference Include="..\Mirage.Godot\src\Mirage.Core\Mirage.SocketLayer\Mirage.SocketLayer.csproj" />
 </ItemGroup>
 <Target Name="PostBuild" AfterTargets="PostBuildEvent">
   <Exec Command="dotnet build ..\Mirage.Godot\src\Mirage.Core\Mirage.CodeGen\Mirage.CodeGen.csproj -c Release" />
   <Exec Condition=" '$(OS)' == 'Windows_NT' " Command="..\Mirage.Godot\src\Mirage.Core\Mirage.CodeGen\bin\Release\net8.0\Mirage.CodeGen.exe $(TargetPath) -force" />
   <Exec Condition=" '$(OS)' == 'Unix' " Command="..\Mirage.Godot\src\Mirage.Core\Mirage.CodeGen\bin\Release\net8.0\Mirage.CodeGen $(TargetPath) -force" />
   <Error Condition="$(ExitCode) == 1" />
 </Target>
 <Target Name="PrePublish" BeforeTargets="Publish">
   <Exec Command="dotnet build ..\Mirage.Godot\src\Mirage.Core\Mirage.CodeGen\Mirage.CodeGen.csproj -c Release" />
   <Exec Condition=" '$(OS)' == 'Windows_NT' " Command="..\Mirage.Godot\src\Mirage.Core\Mirage.CodeGen\bin\Release\net8.0\Mirage.CodeGen.exe $(PublishDir)$(TargetFileName) $(TargetDir) -force" />
   <Exec Condition=" '$(OS)' == 'Unix' " Command="..\Mirage.Godot\src\Mirage.Core\Mirage.CodeGen\bin\Release\net8.0\Mirage.CodeGen $(PublishDir)$(TargetFileName) $(TargetDir) -force" />
   <Error Condition="$(ExitCode) == 1" />
 </Target>
</Project>

Notes

Mirage.CodeGen.csproj currently uses reference to Mirage.Godot.csproj to find Mirage types, but when running will use the types inside the target csproj.

Setup commands

Commands to run steps above (replace path/to/project with your project)

git clone git@github.com:James-Frowen/Mirage.Godot.git
cd Mirage.Godot
cp src/Mirage.Godot/Scripts "path/to/project/Mirage.Godot"
dotnet build src/Mirage.Core/Mirage.CodeGen/Mirage.CodeGen.csproj -o ./CodeGen

and then add PostBuild target manually with path to CodeGen/CodeGen.exe

note: you may want to exclude the src/Mirage.Godot/Scripts/Example1 folder when building or it will end up in the Mirage.Godot dll

Code Generation

Mirage.Godot uses Mono.Cecil to modify the c# source code after it is compiled, this allows for features to have high performance and easy to use.

To Setup add this code to the default csproj for the godot project

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
  <Exec Condition=" '$(OS)' == 'Windows_NT' " Command="path/to/Mirage.CodeGen.exe $(TargetPath) -force" />
  <Exec Condition=" '$(OS)' == 'Unix' " Command="path/to/Mirage.CodeGen $(TargetPath) -force" />
  <Error Condition="$(ExitCode) == 1" />
</Target>
<Target Name="PrePublish" BeforeTargets="Publish">
  <Exec Condition=" '$(OS)' == 'Windows_NT' " Command="path/to/Mirage.CodeGen.exe $(PublishDir)$(TargetFileName) $(TargetDir) -force" />
  <Exec Condition=" '$(OS)' == 'Unix' " Command="path/to/Mirage.CodeGen $(PublishDir)$(TargetFileName) $(TargetDir) -force" />
  <Error Condition="$(ExitCode) == 1" />
</Target>

and modify the Path/To/Mirage.CodeGen.exe path to where you built the Mirage.CodeGen.exe file.

Note, both targets are required:

  • TargetPath works best in editor to ensure code gen changes are applied before running
  • PublishDir is needed because TargetPath is not the path copied when exporting the build

Development

The example use symlinks to include the Mirage.Godot scripts in the 2nd project.

To clone this repo with those symlinks run as administrator:

git clone -c core.symlinks=true git@github.com:James-Frowen/Mirage.Godot.git

If downloading without symlinks (like from zip file) then you will need to manually copy (not move) the files from src/Mirage.Godot/Scripts to src/Mirage.Godot.Example1/Mirage.Godot

Codegen

when developing the code gen locally you might want to add this step to the start of PostBuild targets so that it will rebuild the codegen project before running it

    <Exec Command="dotnet build $(ProjectDir)/../Mirage.Core/Mirage.CodeGen/Mirage.CodeGen.csproj -c Release" />