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?
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.
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:
ā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.
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
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
Ok, it seems to work now, i just had to put āusing System;ā in the file to see it Yes, iām stupid.
But finding a lot of āusing System.Memory;ā mentioned all over Google related to this also didnāt help.