C# comes to Unreal Engine

On a daily basis, I use dozens of different programming languages.  Some languages are certainly better than other languages at certain tasks, while other languages truly shine on certain platforms.  Some languages are more portable than others, others are more customizable while some can be faster.  All that said, when all other things are equal and I need to just pick a language, the one I go to is generally C#.  C# just strikes that right balance for me, straddling the line between low level and productivity, convenience and speed, functional and procedural, for me at least.  This news then is welcome, for me at least. 🙂

Xamarin, the maker’s of Mono, a cross platform open source version of the .NET runtime and framework (Perhaps most famously known as the language technology that underpins Unity)  have announced they are bringing it to Unreal Engine.  Here are some of the features and benefits of Mono for Unity:

Hot Reload

We fully support Unreal Engine’s Hot Reload functionality.

This means that whenever you rebuild your C# code in Xamarin Studio, your changes are immediately reloated into the Unreal Editor. The changes are also reflected with running games in the editor, so you can quickly iterate on your design.

On fast machines, the process of rebuilding the C# code and reloading it live takes less than a second. It feel instantaneous.

Xamarin Studio

While hard core hackers are happy editing their game code with vi or emacs and have the hot reload functionality do all the work for them, we have also provided a nice integration with the MonoDevelop (and Xamarin’s branded version, Xamarin Studio).

It provides a first-class IDE with rich, accurate code completion, and powerful refactoring and analysis tools.

Debugging

Full support for C# debugging is included. Simply launch your game from Xamarin Studio as a standalone editor or mobile preview process, and it will connect to the runtime debug engine, giving you full access to a rich suite of abilities to inspect and debug your code.

Seamless Blueprint and Editor Integration

Your C# classes that are exposed to Unreal Engine are fully accessible from Blueprint and the Unreal Editor, just like Blueprint-accessible C++ classes.

You can continue using Blueprint for simple logic and use C# when things get more complicated.

And you can consume your C# classes from Blueprint.

Mixed C#/C++/Blueprint Solutions

The same tool that we use to generate bindings to Blueprint-exposed Unreal Engine APIs is integrated into Unreal Build Tool, and will automatically generate bindings to all of your Blueprint-exposed C++ gameplay code and engine modifications.

Native Access

In addition to the automatically generated bindings to Blueprint-exposed Unreal C++ code, the Mono runtime allows accessing any native APIs, including custom C/C++ code and the native platform API.

You can manually bind C APIs using Platform Invoke services, or use CppSharp to generate bindings to C++ APIs.

Async Programming

The Getting Started tutorial shows the low-level approach to defining behaviors, but this approach can become cumbersome when defining more complex behaviors and AI. Luckily, this task can be simplified with async programming, a C# compiler feature that rewrites what appears to be linear code into a state machine.

For more details about how this helps writing complex gameplay logic, see our overview of async programming.

API Profile

The Mono Mobile Profile is the core API profile in the support for Unreal Engine.

The Mono Mobile Profile removes a number of bloated .NET features including System.Configuration support from the Base Class Libraries. This is the same API profile used by Xamarin’s Android, iOS and Mac products.

Note: The Mobile Profile is not ABI compatible with existing assemblies compiled for a different profile (like the .NET desktop, Silverlight or Windows Phone). You mustrecompile your source code to generate assemblies targeting the Mobile profile.

A full list of the assemblies in our Mobile framework profile can be found here.

Portable Class Libraries

You can use Portable Class Libraries with Xamarin’s Unreal Engine support. This allows the same binary library to be shared across a wide range of platforms without code modifications.

To learn more about using Portable Class Libraries with Xamarin, read our Introduction to Portable Class Libraries document.

There are a couple of limitations.  It’s based on .NET up to 4.5, with a smattering of .NET 5 features.  Well, async, which is frankly the .NET 5 feature.  Perhaps the biggest limitation is it only has access to code from the Blueprint API.  Given that the Blueprint API has access to just about everything C++ does, this isn’t perhaps the limitation it sounds like.  If you want to make more C++ accessible to .NET you need to use CppSharp.  Additionally, Unreal AND Mono need to be available on the targeted platform, although frankly, Mono is available just about everywhere these days.  However, right now only Windows and Mac are supported, with other platforms under development.

Oh yeah, there is of course one other big side effect… money.

To redistribute code written with Mono for Unreal Engine, you must have a commercial license to the Mono runtime. These licenses are available from Xamarin for Mac, Android and iOS online, and you can request Windows licenses through support.

This of course is completely reasonable.  People make their money selling software, so obviously they have to sell their software.  That said, I’ve always found Xamarian’s licensing to be a bit awful.  There are almost unique in the development world for not offering a (real) free version for non-commercial development and this is a huge mistake IMHO.  The lack of a free edition makes open source software around their tools pretty much non-existent.  Of course, you can open source work made with Xamarian tools, but good luck building a community around a commercial only development product.

That said, this is still an interesting development and one more feather in Unreal Engine’s cap.  Given that Unity is moving away from Mono and developing their own runtime, it’s not entirely shocking that Xamarin made this move.  It is somewhat ironic that the Unreal Engine .NET runtime will be substantially newer and more complete than Unity’s!


Scroll to Top