Mono versions bundled with Unity

Hello,

could you please provide information which version of Unity uses which version of Mono?

E.g., does Unity 2018.3 come with 5.16.0? Would be nice to be able to use the 32bit floating math and the Span with the intrinsics based implementation. Or will I have to wait for later versions of Unity?

1 Like

There is not a direct mapping between Unity versions and Mono versions, since we pull the Mono source code and modify it. Unity does support specific .NET profile versions though. In Unity 2018.3, you can choose either .NET 4.7.1 or .NET Standard 2.0. Unfortunately Span is not available in either.

In a future version of Unity we do plan to support .NET Standard 2.1, where Span is available. You can follow the development of .NET Standard here: GitHub - dotnet/standard: This repo is building the .NET Standard

4 Likes

So for the time being I can only use the slow ā€œportableā€ System.Memory package from NuGet, right?

Also, once you will support the .NET Standard 2.1, will you bundle the actual ā€œfastā€ implementation?

As for .NET Standard 2.1 support, are there any plans? E.g., is there a chance we will see it in the 2019 cycle?

3 Likes

Hello,

Sorry to hijack this thread but it seemed fitting, Iā€™m currently trying to set up my codebase with the System.Memory package but when I run my code I get
System.IO.FileNotFoundException : Could not load file or assembly ā€˜System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aā€™ or one of its dependencies.

Iā€™ve added the System.Memory.dll by using Nuget and afterwards copying the file from <ProjectRoot>Packages\System.Memory.4.5.1\lib\netstandard2.0\ to <ProjectRoot>\Assets\Libraries\

I noticed that one of the Unity Packages I installed is referencing a different System.Runtime.CompilerServices.Unsafe.dll:

F:/projects/Ironbyte.Unity/Library/PackageCache/com.unity.collections@0.0.9-preview.10/System.Runtime.CompilerServices.Unsafe.dll

Should I also copy <ProjectRoot>\Packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\ wouldnā€™t that interfere?

Cheers,

@poettlr Unity.Collections exception - #10 by system

1 Like

ā€œIn a future version of Unity we do plan to support .NET Standard 2.1, where Span is available.ā€

According to Project settings in 2021.2.2f1, my project is using ā€œNet Standard 2.1ā€ - but for some reason Span<> does not show up in Visual Studio.

Do i have to change anything else ? Or is Span<> not in Net Standard 2.1 after all ?

I donā€™t think you should have to change anything else. Does the C# code compile in Unity? If so, make sure you are using Visual Studio 2019 or later.

It compiles, and iā€™m on latest VS 2019.
This machine is on Win7 though, if that makes any difference. ( Too old and specialized to switch to 10, but i have another machine thatā€™s on 10 )

I also tried to make a fresh project, the former one was imported from an earlier version.
But that also doesnā€™t make Span<> show up.

Maybe have a look at the generated .csproj file that VS is using. I wonder if it is using an older language version or target framework version.

TargetFramework seems to be set to 4.7.1 in that file.
I just installed 4.8 Developer Pack, and the DotNet 5.0 SDK, but making a new project still targets it at 4.7.1.
Changing that setting to 4.8 also does nothing it seems.
Not even sure what value is supposed to be there to make this work :slight_smile:

I also canā€™t right-click on the Assembly-CSharp project to get to the properties, it just makes VS blink and never open the Properties window ā€¦ lovely.

Oh well - itā€™s not that important right now. Donā€™t want to delve into some deep Microsoft Rabbit-Hole to get it working ( or learn that itā€™s yet again something that is now breaking because Win7 was abandoned ). I know too little about C# in general.

Extra : Setting the Target to 5.0 shows a ā€œDownload Targeting Packā€ option, when used it loads an empty Bing Page. ( The Targeting Pack was actually installed with the DotNet 5.0 SDK - but apparently Visual Studio doesnā€™t ā€œseeā€ it somehow ? ) Thanks MS :slight_smile:

Ok, it seems to work now, i just had to put ā€œusing System;ā€ in the file to see it :smile: Yes, iā€™m stupid.
But finding a lot of ā€œusing System.Memory;ā€ mentioned all over Google related to this also didnā€™t help.

1 Like

Iā€™m glad you were able to sort it out!

1 Like