A Game Designed to Teach Beginners C# in a quick interactive way using the Roslyn Compiler.
The Unity C# Trainer uses the Roslyn compiler to dynamically compile user-written code in real time. This allows beginners to learn C# interactively while seeing their scripts affect objects inside the scene.
When the player clicks Compile, their script is parsed into a syntax tree and passed into a Roslyn compilation pipeline. Any previous runtime script instances are safely disposed to avoid memory leaks.
Unity does not allow runtime compilation natively, so the game uses Roslyn to generate an in-memory DLL containing the player’s script. All currently loaded assemblies are included as references so the script can access Unity APIs safely.
Once the in-memory DLL is created, the trainer searches for the first class that extends
MonoBehaviour. This becomes the script that will run inside the game world.
For the final challenge of the trainer, the game spawns a fully interactable character. The user’s compiled script is attached as its controller, teaching how real game logic drives gameplay.
If the user writes an Update() method, the trainer invokes it manually,
effectively simulating how Unity’s real MonoBehaviour lifecycle works.
The trainer supports loading scripts from external files, and injecting template code directly into the editor to guide beginners through challenges.
Still in Active Development, Visit the Itch Page Below