Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Mono versions bundled with Unity

Discussion in 'Experimental Scripting Previews' started by pavelkouril, Dec 22, 2018.

  1. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    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<T> with the intrinsics based implementation. Or will I have to wait for later versions of Unity?
     
    phobos2077 likes this.
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    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<T> is not available in either.

    In a future version of Unity we do plan to support .NET Standard 2.1, where Span<T> is available. You can follow the development of .NET Standard here: https://github.com/dotnet/standard
     
  3. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    129
    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?
     
  4. poettlr

    poettlr

    Joined:
    Mar 4, 2015
    Posts:
    17
    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:
    <Reference Include="System.Runtime.CompilerServices.Unsafe">
    <HintPath>F:/projects/Ironbyte.Unity/Library/PackageCache/com.unity.collections@0.0.9-preview.10/System.Runtime.CompilerServices.Unsafe.dll</HintPath>
    </Reference>

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

    Cheers,
     
  5. nxrighthere

    nxrighthere

    Joined:
    Mar 2, 2014
    Posts:
    567
  6. datRebb

    datRebb

    Joined:
    Apr 4, 2017
    Posts:
    6
    "In a future version of Unity we do plan to support .NET Standard 2.1, where Span<T> 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 ?
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    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.
     
  8. datRebb

    datRebb

    Joined:
    Apr 4, 2017
    Posts:
    6
    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.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    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.
     
  10. datRebb

    datRebb

    Joined:
    Apr 4, 2017
    Posts:
    6
    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 :)
     
    Last edited: Nov 17, 2021
  11. datRebb

    datRebb

    Joined:
    Apr 4, 2017
    Posts:
    6
    Ok, it seems to work now, i just had to put "using System;" in the file to see it :D Yes, i'm stupid.
    But finding a lot of "using System.Memory;" mentioned all over Google related to this also didn't help.
     
    JoshPeterson likes this.
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm glad you were able to sort it out!
     
    datRebb likes this.