A lightweight toolkit that bridges Unity 6+ to modern C# language features.
Unity Editor → Window ▸ Package Manager
➕ Add package from Git URL
https://github.com/Braneloc/ModernCSBridgeUnity.git
Unity downloads the package and recompiles scripts automatically.
Your project **must ** be compiling correctly before/while installing (ie not using C#10+ features)
- Full usage of C# 10+ for Unity
- Support for records and init-only setters.
- Unity compiles C# projects in “9.0” mode by default. New syntax such as record, init setters, and enhanced switch expressions may fail to compile or show IDE errors.
- System.Runtime.CompilerServices.IsExternalInit is missing in Unity’s .NET Standard 2.1 runtime, causing CS0518 when you compile records or use init.
-
Every time Unity regenerates its C# project files, the bridge bumps the LangVersion element to latest version of C#. No manual action required.
-
Manual stub generation
Right‑click any folder in the Project window and choose either menu path:
Create ▸ Support Code ▸ IsExternalInit
Create ▸ Scripting ▸ IsExternalInit
If IsExternalInit.cs already exists in that folder, the command overwrites it in place. The stub is wrapped in #if !NET8_0_OR_GREATER, so it compiles away automatically once Unity moves to a .NET 8‑based runtime that includes the real type. -
Bonus: Under Unity Project Settings, Player, it might be helpful to add under additonal compiler arguments:
-langversion:latest