An opinionated quick-start template for Godot 4 projects using C# and aiming not to deliver games, but rich desktop applications.
- A C# ready setup.
- A unit-test C# project is included.
- A directory and namespace structure that promotes a separation of the presentation and business layers.
- All presentation logic is what's happening inside of Godot's systems. Godot artifacts are separated by type by default and bundled together when reasonable. For example, components are structured so as to be as self-contained as possible.
- All actual business logic is to be handled by C#.
- An input validation framework, with working examples.
- A data source framework, with working example.
- This is a suggestion for how to read and write data from and to disk.
While this project is designed to include most of the necessary parts for a running start, it cannot provide everything.
- Make sure to have read and understood the official Godot tutorial: https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_basics.html
- This project requires the .NET Framework
v6.0. - This project has been set up with the
Godot_v4.0.2-stable_mono_win64Godot binaries.- The exact version shouldn't matter, but in case you run into odd issues not outlined here, make sure to test it with this exact version also.
- In case you're not working with Visual Studio, you may need to invoke NuGet manually, to download dependencies. Current dependencies are outlined below.
- UTF8Json
After having cloned this repository, you should be able to build and run the project right away. Then, make it your own:
- Change out the
app/icon.pngimage for your own. - Change the name of the project to your own. For that, in Godot, navigate to
Project > Project Settings > Application > configand change the name to your preference. Be mindful that changing the name affects several other things in Godot, such as the name of the user-specific data directory. - If you're working with Visual Studio, the solution file can be found in the project's root directory and is called
project.sln. - Write your model of business data, inside the
app/business/modeldirectory and integrate your model into theapp/business/state/ApplicationState.csclass. - Define the application-level settings as fields inside the
app/business/state/ApplicationSettings.csclass.
- Due to how Godot automatically adds the contents of the Godot project to the Godot associated C# project, it is best practice to avoid adding C# sub-projects within the directory structure of the Godot project.
- In the case of this template, avoid adding sub-projects inside of the 'app' directory. Instead, place them one level up in the root of the cloned directory structure.
- In order to get NuGet to work with Godot's C# project setup at all, it was necessary to add a
nuget.configfile to the root directory of theappC# project.- The essential problem with Godot C# projects as they come out-of-the-box (from Godot version 3.3.0 and up), is that they require the
Godot.NET.Sdk/<version>sdk to work. This sdk is supposed to be downloaded by NuGet. However NuGet doesn't seem to know where to get it from, by default. - This issue is separate from Visual Studio - it is NuGet itself, which isn't playing nice.
- For more details, see this git issue: godotengine/godot#58955
- The essential problem with Godot C# projects as they come out-of-the-box (from Godot version 3.3.0 and up), is that they require the