Programming in C#

Turian is written in C# on .NET 10, and your game scripts are C# too — the same language as the engine, with no bindings or scripting dialect to learn. If you know Unity, most of the shape will feel familiar: a class that inherits from Component, overridden callbacks such as OnStart and OnUpdate, and public fields shown in the Inspector.

Code editors

Any C# editor works. For completion, navigation and inline errors, open the project file Turian generates for your scripts:

<project>/.Cache/Source/<ProjectName>.csproj

It references your Assets/**/*.cs files and the engine assemblies, and is regenerated whenever Turian compiles.

Editor Setup
Visual Studio Code Install the C# Dev Kit, then open the generated .csproj.
JetBrains Rider Open the generated .csproj.
Visual Studio Open the generated .csproj (Windows).
Zed, Neovim, Helix Use an LSP client with csharp-ls or Roslyn LSP pointed at the generated .csproj.

Turian Studio does not edit code itself: double-clicking a script in the Assets panel opens it in the program your desktop associates with .cs files.

How your code is built

  • In Studio, saving a script triggers a background compile with Roslyn. The new assembly is loaded without restarting the editor, and errors are listed in the Output panel.
  • turian-cli compile does the same headlessly.
  • Export (turian-cli export or Project → Export) builds the scripts together with the engine in Release mode and publishes a self-contained, single-file executable with dotnet publish.

Because Turian uses the regular .NET SDK, your scripts can use any C# feature supported by .NET 10 and the whole base class library.

Conventions

  • Put scripts anywhere under Assets/; one component class per file, named like the file.
  • The default namespace of new projects is Usercode; any namespace works.
  • Nullable reference types are enabled. Node is null until a component is attached, so use Node! inside lifecycle callbacks, where it is always set.
  • Implicit usings are off. New projects get an Assets/Globals.cs with global using lines for the engine (Turian.Engine.Core, Turian.Engine.UI), its attributes (Turian), System, System.Linq, System.Numerics, logging and the Silk.NET input key codes; add your own there.
  • Log through Log.Logger, a standard Microsoft.Extensions.Logging.ILogger.

Math types

Turian uses System.NumericsVector2, Vector3, Vector4, Quaternion and Matrix4x4 — which are SIMD-accelerated by .NET. Mathf adds helpers and constants such as Mathf.Forward, Mathf.Up and Mathf.DegreesToRadians.


← All docs Edit this page