Documentation
C# Scripting
Experimental managed C# scripting via Mono/.NET runtime embedding.
Warning
Overview
Modularity can host managed C# scripts via the .NET runtime. This is an early, minimal integration intended for movement/transform tests and simple Rigidbody control.
The managed API surface is tiny for now: position/rotation/scale, basic Rigidbody velocity/forces, settings, and console logging.
Managed project files are under Scripts/Managed (separate from Assets/Scripts used for native scripts).
Setup
- Build the managed project (this now happens automatically when you compile a C# script):
dotnet build Scripts/Managed/ModuCPP.csproj - In the Inspector, add a Script component and set:
- Language =
C# - Assembly Path =
Scripts/Managed/bin/Debug/netstandard2.0/ModuCPP.dll(or point at a.csfile inScripts/Managed/) - Type =
ModuCPP.SampleInspector
- Language =
- Enter play mode. The sample script will auto-rotate the object.
Requirements
- The
ModuCPP.runtimeconfig.jsonproduced bydotnet buildmust sit next to the DLL. - The managed host currently expects the script assembly to also contain
ModuCPP.Host(use the providedScripts/Managed/ModuCPP.csprojas the entry assembly). - Requires Mono runtime support in the engine build plus dotnet to compile the managed project. If runtime setup is missing, the engine will fail to initialize managed scripts and report the error in the inspector.
Hook Exports
Managed hooks are discovered by method name (Script_Begin or Begin, Script_TickUpdate or TickUpdate, etc.) with signatures that accept a context pointer and optional delta time.
Mono Embedding
This project uses Mono embedding for managed (C#) scripts.
Expected Layout (Vendored)
include/mono-2.0/
lib/ (or lib64/) with mono-2.0-sgen library
etc/mono/ (config files)
lib/mono/4.5/ (framework assemblies)Runtime Override
You can override the runtime location at runtime with:
MODU_MONO_ROOT=/path/to/monoBuild Notes
- The CMake cache variable
MONO_ROOTcontrols where headers/libs are found. - Managed scripts target
netstandard2.0and are built withdotnet build.