Unity 3D Using Latest C# version (C# 7.1)

Tasks in Unity

As you know there is no way to use System.Threading.Tasks in Unity 3D as normal way. This library is no accessible in default unity 3D project template. You should use IEnumerator to use continuously background activities or tasks. If you could use latest C# version you can use Tasks too.

Lambda Expressions in Unity

In Unity, you can use LINQ methods and send parameters into them as Func with lambda expressions but, property get and set mothods or single line method writing is not supported in default in Unity.

.Net Framework in Unity

A default Unity 3D project supports .Net Framework 3.5 with C# 4.0. Why it does not contain latest versions of these?

When Unity compile a project, takes all your C#code and serialize them to convert C++ to create a C++ Library. It’s not easy to support immediately newest versions. But there is a way to use latest .Net Framework and C# version in unity projects but there is a warning by Unity: It’s not stable. I’m using latest version and I haven’t got any negative situation until now. Let’s see how to use latest libraries:


Upgrading Latest C# and .Net Framework

Go File>Build Setings In Unity Editor. See this windows like below:

Unity 3D Player Settings Enis Necipoglu using latest .Net Framework Version C#

Click to Player Settings from here. Some properties will come to the Inspector window which is going to be like:

Unity 3D Build Settings Enis Necipoglu using latest .Net Framework C#

Go to Other Settings windows from here and find Scripting Runtime Version property. Switch it to .Net Framework 4.6

Unity 3D Build Settings scripting runtime version using latest .Net Framework C# Enis Necipoglu





Then you need to restart your Unity 3D. After restarting go your editor and use latest features without any Errors.

Add a Comment

Your email address will not be published. Required fields are marked *