Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity supports C# 3.5 or 2.0?

Discussion in 'Scripting' started by willyfreddy, Nov 10, 2011.

  1. willyfreddy

    willyfreddy

    Joined:
    Mar 28, 2011
    Posts:
    50
    Hi there,

    In this link here it is stated that Unity supports C# 3.5: http://forum.unity3d.com/threads/72846-Does-unity-supports-.net-3.5-or-4.0.

    However on this reference page it mentions that you can set your compatibility level in the project settings. When I go to Edit->Project Settings->Player, it only gives me an option of choosing .NET 2.0 and .NET 2.0 subset.

    What am I missing here?

    Thanks,

    Will
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Unity is C# 3.5, but .NET 2.0 CLR compatibility and the '.NET 2.0' libraries (you can't really call it like that casue system.linq etc are present)

    As its mono and not MS.NET, thinking about the MS.NET versions isn't that helpfull, the only relevant thing is that anything thats compiled for .NET4 in VS will not go to unity (same for anything that uses MS.NET only frameworks)
     
  3. willyfreddy

    willyfreddy

    Joined:
    Mar 28, 2011
    Posts:
    50
    Okay, so lemme see if I got this right: The version of Mono that Unity uses (2.6.x) provides support for C# 3.5 but only provides compatibility for .NET 2.0 (as demonstrated in the Edit->Project Settings->Player). However, that's not actually true, because to utilize LINQ (for ex.) within C# you require a .NET library that's from after 2.0.

    So, in other words, it's not possible for Mono to support C# 3.5 without also adding SOME support for .NET 3.5.

    Is that correct?

    Cheers,

    Will
     
    Last edited: Nov 10, 2011
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Basically it supports 3.5, but unity has a custom mono version with some custom things:

    1. the non-core assemblies are not auto copied into the build, you have to manually copy them into Assets/Plugins for example
    2. They have removed some stuff
    3. more importantly for mobile and webplayer its really only a subset with major cuts.

    The 2.0 there is likely a good reflection of what you have at least :)
    I've so far gotten through without problems.


    If you want to know whats in and what not by the way there is an extremely long list on the page on which classes and namespaces are available on which platform
     
  5. willyfreddy

    willyfreddy

    Joined:
    Mar 28, 2011
    Posts:
    50
    Alright, thanks. I think I understand it well enough for now :)

    For any other readers, I believe he is referring to this list here.

    Thanks again,

    Will
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    exactly that one :)
    you need quite some patience for it to load completely ... even on my 20mbit down line it takes several minutes normally until its complete ... ;)