Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity C#'s version?

Discussion in 'Scripting' started by leegod, Sep 18, 2015.

Thread Status:
Not open for further replies.
  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    So up to what version unity c# support now?

    5.0? or 6.0?
     
  2. MadeThisName

    MadeThisName

    Joined:
    Mar 14, 2015
    Posts:
    115
    You can run this to check the version
    Code (CSharp):
    1. Debug.Log(System.Enviroment.Version);
     
    leozhang1, dCalle and TharosTheDragon like this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Wait, is there an announcement I missed?

    Last I heard we are using an old version of Mono, roughly equivalent to .Net 3.5.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No announcement, nothing has changed.

    --Eric
     
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    They're not asking for the framework version. They're asking for the version of the language itself.
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Ryiah likes this.
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    Ah. Got it. I was trying to dig up if they were decoupled or not, but I didn't think to check the Wiki.
     
  8. MadeThisName

    MadeThisName

    Joined:
    Mar 14, 2015
    Posts:
    115
    You can use some reflection to find out :):
    Code (CSharp):
    1.     usingSystem.Reflection;
    2.     Type type =Type.GetType("Mono.Runtime");
    3.     if(type !=null)
    4.     {
    5.     MethodInfo displayName = type.GetMethod("GetDisplayName",BindingFlags.NonPublic|BindingFlags.Static);
    6.     if(displayName !=null)
    7.     Debug.Log(displayName.Invoke(null,null));
    8.     }
     
    Last edited: Sep 18, 2015
  9. MadeThisName

    MadeThisName

    Joined:
    Mar 14, 2015
    Posts:
    115
    Last i checked it was Unity 5.1 with NET 2.6.5
     
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Ryiah likes this.
  11. MadeThisName

    MadeThisName

    Joined:
    Mar 14, 2015
    Posts:
    115
    lol It seems im missing the mark every time.......I think nows the time for me to shut up.
     
    MD_Reptile likes this.
  12. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Its all good. Most of my Unity knowledge is just copied from @Eric5h5's old posts. :)
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    (Wonder if I should tell him that I just make everything up.)

    --Eric
     
    Ioplop, Pecek, MD_Reptile and 4 others like this.
  14. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
  15. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,200
    Just a reminder, from the Roadmap under "IN-PROGRESS, TIMELINES LONG OR UNCERTAIN":


    Also, since the numbering is confusing; Unity uses Mono version 2.6.5-with-some-extra-features (I believe), which supports C# 3. The latest version of Mono is Mono 4, which supports C# 6.

    Even a "simple" jump up from 2.6.5 to 2.8 would give us C# 4 and a generational GC, so that would actually be huge.

    Mono 2.6 was released back in 2009, while 2.8 was out in 2010. Unity has some real big technological debt here.
     
    Kiwasi likes this.
  16. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
  17. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    wtb linq and lambda expression for Unity
     
  18. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    LINQ extension methods and lambda expressions work just fine in Unity.
     
  19. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    .NET 4.5 or is that new in Unity 5+ ?
     
  20. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    What about it?
     
  21. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    using System.Data.Linq; Namespace works for Unity ? I get error if i try. But normal Linq is fine.

    Useful for SQl and database. 4.0 + i believe is the framework.
     
  22. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    No. Like I said - the extension methods in System.Linq work. And lambda expressions work.

    While full LINQ support might be useful for querying collections you can still get there with the extension methods. Beyond that - I really wonder how much database work you're doing inside Unity itself.
     
  23. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Querying Database with Linq is base line now days. Using adapter is pretty old fashion. Do I use database allot? Yes I do. I can't imagine me not using it. Thought I do compile things in standalone application with Unity. Thought basic Linq is fine for Unity I am quit happy.
     
  24. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    So you're packaging database instances up with your games? Or you're directly connecting to and querying a remote database? Both of those seem like bad ideas to me - unless there is another way to use that functionality. Admittedly, I'm not super familiar with it.
     
  25. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    No, no and no.. There are tons of ways to work with a database.
     
  26. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,345
    I want to know your way of usage of database, other than connect to remote server db.
     
  27. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Ok? Care to enlighten? The first step would be "connecting to it" which means it's either Here or Somewhere Else.
     
  28. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Well i dont want to get to deep on it public, but your right, the connection has to be some where :) For mobile I been using Local connection with a "backdoor" connection to a external application. But I am working on a whole new version with Ulink, maybe I put in in asset store for does who like to use mssql, (its not mono). The data stream is encrypted and obfuscated, so is the connection.
     
    Last edited: Sep 18, 2015
  29. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Sounds interesting but seems needlessly complicated. Wouldn't it be simpler to just send a GET to the server and let it do the querying? Especially if the server application was also C# in which case your data models could be a shared DLL between it and your Unity client.
     
  30. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    For small simple games that is more complicated than necessary, because you can have the networkSync/cloud RPC on Ulink but database on separated server.
     
  31. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    C# 3.0 with additional support for named and optional arguments from C# 4.0.
     
    MaxPirat likes this.
  32. eskivor

    eskivor

    Joined:
    Aug 5, 2015
    Posts:
    13
    I have Unity 2017.1.0f3 ant it prints "2.0 (Visual Studio built mono)" or "2.0.50727.1433" depending the methods that are shown just above.

    Is that normal, that is so low with me ? Is it only linked to the Unity version or are they other parameters that affects it ?
     
  33. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,148
    If it's showing you those numbers it's because you haven't set it to use the newer framework.

    https://blogs.unity3d.com/2017/07/11/introducing-unity-2017/

    Scroll or search for the section named Scripting Runtime upgrade then follow the instructions there to switch it.
     
  34. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    I wonder if all the 6.0 C# features works with mono.. any info on what works or not?
     
  35. TharosTheDragon

    TharosTheDragon

    Joined:
    Sep 2, 2017
    Posts:
    13
    I'm using Unity 2017. Both Environment.Version and Mono.Runtime.GetDisplayName() return 2.0. I don't know where 2.6.5 comes in.

    The C# version seems to be 4, or at least it says that whenever I try to use a language feature that isn't supported.

    But one bizarre idiosyncrasy is that I can use readonly automatically implemented properties even though they apparently weren't introduced until C# 6.
     
  36. nat42

    nat42

    Joined:
    Jun 10, 2017
    Posts:
    353
    What have you got set in Player Settings (see Ryiah's link above) for the "Scripting Runtime Version" and "API Compatibility Level" ?
     
  37. TharosTheDragon

    TharosTheDragon

    Joined:
    Sep 2, 2017
    Posts:
    13
    "Stable (.NET 3.5 equivalent)" and ".NET 2.0"
     
  38. Hkstrongside

    Hkstrongside

    Joined:
    Aug 29, 2013
    Posts:
    1
    Awesome, thanks! Now I am able to use String Interpolation.
     
  39. Gocs

    Gocs

    Joined:
    Oct 16, 2017
    Posts:
    1
    Here is how I get:
    Code (CSharp):
    1. Debug.LogFormat("Version: {0}", typeof(string).Assembly.ImageRuntimeVersion);
     
  40. sj631

    sj631

    Joined:
    Dec 23, 2016
    Posts:
    22
    Where did you find this
     
  41. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    Probably from Unity's website 7 years ago. Try to check the date of the thread before necroing something. The first Google result of "Unity C# Version" leads me to this page, which says it's running version 9.0.
     
    Kurt-Dekker likes this.
Thread Status:
Not open for further replies.