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
  2. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  3. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

.Net 5 support

Discussion in 'Experimental Scripting Previews' started by Lymdun, Mar 3, 2020.

  1. gilick

    gilick

    Joined:
    Feb 2, 2021
    Posts:
    1
    Any updates on .NET 5/CoreCLR?

    On another note, the Mono team has put up issue and PR related to the current embedding API; It's getting deprecated!

    User story about moving to modern .NET stack: https://github.com/dotnet/runtime/issues/47763
    PR about embedding API deprecation: https://github.com/dotnet/runtime/pull/47715

    Also for the curious one, here's some news about the state of AppDomain's in .NET 5 Mono, they are still there, but just for Mono. Old-ish blog but relevant information: https://www.mono-project.com/news/2020/08/24/native-loader-net5/
     
    Qbit86 likes this.
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I don't have any updates to share now. I can say that we are actively working on this now. However, this is a likely multi-year process. We do expect to have various parts of it available before everything is complete though.
     
    Kirsche, Vincenzo, Jobus and 12 others like this.
  3. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    Do we have any update about these? At least, if the document would be updated, which page will be related to this issue?
     
  4. Vincenzo

    Vincenzo

    Joined:
    Feb 29, 2012
    Posts:
    146
    Any update on the upgrade of moving to latest Mono master runtime?
     
    PerfidiousLeaf and Qbit86 like this.
  5. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
  6. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    That is for the Editor itself probably. My bet is that we won't get .NET 5 for the runtime, but NET6, and it will be in sometime 2022.

    @JoshPeterson ?
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Nothing to share publicly about release dates yet. But I'm knee-deep in doing this exact task at the moment. :)
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Yeah, this is to run a newer Roslyn version that must run with .NET 5. We're not yet ready to move the editor and the entire ecosystem to .NET Core-based though.

    I do expect that will be .NET 6 though, not .NET 5, since .NET 6 is the LTS release from Microsoft.
     
    BrianKesecker and Huszky like this.
  9. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    2022? More like 2024 at best. Check a look the history of Unity
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Fair point! This is something we are actively trying to improve though.
     
    ModLunar, Neonlyte, RGV and 8 others like this.
  11. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    613
    Go Josh!

    I have nothing else ^_^
     
    ModLunar likes this.
  12. jasonboukheir

    jasonboukheir

    Joined:
    May 3, 2017
    Posts:
    84
    It's in 2021.2 alpha ;)

    EDIT: thanks @Lymdun -- it's not actually :(
     
    Last edited: Apr 1, 2021
    dCalle likes this.
  13. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    47
    No, they didn't updated the runtime, only the C# version, we're still (very) far from .Net 5/6 and stuck with an outdated Mono fork
     
    dCalle, Ramobo, NotaNaN and 3 others like this.
  14. jasonboukheir

    jasonboukheir

    Joined:
    May 3, 2017
    Posts:
    84
    *sad developer noises*
     
    ModLunar likes this.
  15. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    I wish unity would fork their editor source out as official repo for changing their scripting backend and build system to dotnet 5 ecosystem, put it in github, and let us contribute it
     
  16. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    269
    Unity is the only major game engine that doesn't allow its users to view and modify its source code. That, in my opinion, sucks ass
     
    Kolyasisan likes this.
  17. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    You can, as a premium-user
     
  18. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,136
    As a premium-premium-premium user.
     
    ModLunar likes this.
  19. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    Indeed. All that you have to do is privately negotiate a source code license, which will cost you about {nda}.
     
    ModLunar, PerfidiousLeaf and cxode like this.
  20. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    47
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Correct, this is the .NET runtime used to run il2cpp.exe itself, not the class library version Unity uses. Work to upgrade Unity to newer class libraries is in progress, but we don't have an ETA for it yet.
     
    TheZombieKiller likes this.
  22. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
    @JoshPeterson
    Would it be possible to get some indication of where the progress of the runtime upgrade is at? For example, maybe a blog post every now and then just describing what's been done or what's left to do at the time? I can't speak for everyone but I know I'd be fine not having an ETA in exchange for progress reports that I could keep an eye out for. Even if the details of the process don't directly apply to users of the engine, it'd be greatly appreciated all the same as something tangible to show that it's being actively worked on.
     
    ModLunar, Huszky, Neonage and 8 others like this.
  23. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I think we need to do a better job of communicating the progress.

    There is always a balancing act between being transparent and making promises. The reality with any software project is that you just don't know how long things will take, so we don't want to promise X feature in Y release when we don't know we will meet that deadline.

    However, we are at the point now where progress toward better .NET alignment will start rolling into releases, so I think that we can communicate more. I'll talk with the team about this and come up with something.
     
  24. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    Maybe just opensourcing what you have done to public repo is the solution (maybe sync once a week or 2 weeks, automatically)

    This is not promising anything and provide the most transparent progress possible
     
  25. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    47
    NotaNaN likes this.
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Thanks @Lymdun, I was going to point that out.

    The other parts of the picture are changes for IL2CPP and Unity Engine and Editor. None of these are open source, and I don't expect them to become open source any time soon, so unfortunately we cannot provide more transparency this way.
     
    NotaNaN likes this.
  27. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    bdovaz likes this.
  28. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    By "true dotnet 5" do you mean CoreCLR as a JIT runtime? That is something we have prototyped internally with some success. It is on the plan to ship CoreCLR as a JIT runtime to replace Mono. However, there are a number of outstanding questions we still need to answer around that.

    I expect that Unity will be able to ship .NET 5 or 6 class library support with Mono as the JIT runtime before moving to CoreCLR, although that is still to be determined.
     
  29. TieSKey

    TieSKey

    Joined:
    Apr 14, 2011
    Posts:
    228
    I think what TheZombieKiller is proposing is not actually promising anything at all. Just sporadic blog posts stating what are u doing right now or what did u finish the day before. So, no promises, no etas, no dates, only stuff already in progress or done.

    When you don't have any promises to fulfil (PR doesn't mess up), sometimes a simple post saying "yeah, slow week, still working on X" is all you need.
     
  30. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    What I wish for the most now is using dotnet ecosystem for exporting unity. Mobile is one thing that I want to use xamarin codebase for ios/android but webassembly is the most I wish for. dotnet system has sophisicate interop system for dealing with js on its wasm export and that was the serious blocking issue using unity webgl for so long

    I know it not unity fault but it was of IL2CPP and emscripten. But if we could switch to dotnet everything would be easier
     
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    We have been discussing this a bit within the team, and this is kind of what we have in mind as well. I'm not sure that it will be updated weekly, but something like this. I'm hoping to have something soon!
     
    cxode, NotaNaN and Huszky like this.
  32. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm curious about the JS interop system the dotnet uses. I'm not too familiar with it. What benefits does it have over what Unity offers? Maybe we can provide it or something similar. Can you start a new forum thread about this maybe?
     
    NotaNaN likes this.
  33. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    Already here

    https://forum.unity.com/threads/net-5-support.839890/page-4#post-6544471

    but seem like there was no progress has been done at all since last year

    There was also another comment about something already exist > https://forum.unity.com/threads/net-5-support.839890/page-4#post-6551857

    But then I ask for more information there was no more response thereafter > https://forum.unity.com/threads/net-5-support.839890/page-4#post-6554983

    And so why should reinventing the wheel though? dotnet ecosystem already have it and will be even better progressively in the future, while we just stuck with emscripten as a ceiling

    Unity would also get benefit from having close relationship with dotnet. There would be many things that dotnet will solve for platform specific and unity engine could be just a framework that rely on those things

    And so I want unity team to focus on this task instead of distract to webgl or anything that just already exist in dotnet
     
  34. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Oh, thanks for pointing this out, I had forgotten about this conversation earlier in the thread. I'll work our WebGL team to get a response to your latest question, I suspect that it was lost in the shuffle. For clarity, can you open a new forum thread with that question, so we can redirect it to a more specific thread?

    Indeed, this is our long term goal. We want to re-use as much of the .NET ecosystem code as well, while customizing parts for Unity users where it matters an ensuring that existing Unity projects continue to work. I think it is just taking us longer to get there than most of us would hope - but this is where we want to be.
     
    bdovaz and NotaNaN like this.
  35. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    I don't know what can I write about that thread. It all just summed up to

    Which I don't know what exactly what it is. It just vaguely mention and I don't even sure it would be satisfied my need. I want to know more about it too. And so we should have official sticky thread about this under > https://forum.unity.com/forums/webgl.84/ < shouldn't we?

    I think, to introduce new build system, it should not need to be support old project. If we want to use new build system we should then start with new project. And keep legacy build system for the old project. I don't even mind that you might create a parallel version of unity completely separate from main version, name it unity.net or anything, as long as it could still be installed by hub

    In fact it could be the same as unity tiny. Which completely throw everything legacy that not related to core system out of the way. We could do the same for pure dotnet build system and bypass IL2CPP or emscripten with this process. It could even be another option of project tiny and dots stack exporting. Unity tiny would be more attractive that it could use dotnet core library more easily
     
  36. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I just wanted to create a new thread to focus the discussion on your unanswered question. I've done that now: https://forum.unity.com/threads/request-for-better-documentation-for-webgl-js-c-interop.1089856/

    Let's continue the discussing about the WebGL JS <-> C# interop there.

    This is an option we have considered. But we feel that there are so many projects in Unity code already, that we don't want to fork the ecosystem. Instead, we want to provide as smooth an upgrade path as possible. This does mean that getting to .NET 6 will take longer than it would with an entirely clean break. But in the long term, we feel that it is better to move the entire Unity ecosystem.
     
    De-Panther, NotaNaN and Huszky like this.
  37. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Writing regularly about stuff like this would be the main benefit of more regular blog posts as you mentioned above. Keep up the good work!
     
    NotaNaN likes this.
  38. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    Sorry that I would like to say I felt totally opposite

    If we have new project format available, we could start new project whenever we want a new project with the new format. And then we most likely stuck a project on a format that create it for eternity. So the quicker the new format was available, the more chance a new project can be start working on it

    I don't have statistics number in my hand but I am very suspect that we can count by hand how many project that start off as old rendering system but then switch to URP system. I think normally people don't even migrate project from each year number. If a project was started from 2017 then they most likely still build that project in unity 2017 even in 2021. And people will start new project on newer unity instead

    I even see some people don't migrate project. They will just start new project in newer version but then migrate only asset they want to that new project to continue on the same project. And so they leave the old repo intact

    It was the traditionally engineering problem. The old project would grow too large and too delicate. Any change introduced leads to requirement of testing everything relate to it. Starting project anew would be easier to use new tech stack

    I think unity should not focus on smooth process for migration of build system, it should not be the main concern. Instead make it more obvious that a change is required for using new system might even be better. So we could consider deprecation of some unused and incompatible more easily
     
    NotaNaN likes this.
  39. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    As a user of the engine, and as one that works with different companies, I hear opinions opposite to @Thaina

    There are companies with games older than 5 years that still make money, still get updates and runs on multiple platforms and stores.

    You mentioned URP - the reason those projects prefer not to update to URP, is that it's a lot of work, and not a smooth thing for large projects, with lots of assets in assetbundles.
    It also means that the users would have to re-download all the assets...

    projects like those, do update Unity when possible - new LTS, new patch that solves a bug, importent platform/store update...

    There are already too much configurations, that it's hard to find good solutions for different aspects of the engine.
    DOTS, ECS, SRP, etc... etc...
    Look at assets on the asset store, in the past it was "supports mobile and desktop".
    Now assets need to support much more configurations, and it's hard to keep up. And confusing for the users
     
    NotaNaN likes this.
  40. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    It sure get updates but I mean it would not upgrade the project to newer unity version

    This, with the same thought process, unity version of the year are the same. Deprecated function, Breaking change and subtle change. Recently I have update from unity 2020 to 2021 and found out that facebook package are not compatible with 2021 networking because it still use `WWW` class for networking

    I'm sure people updates their content and their project but don't really update their underlying system unless it really required

    For what I mean unity version, I mean project that start in unity 2017.0 might be upgrade to 2017.1 or 2017.3 LTS eventually but I'm sure it would be hardly from 2017.3 to 2020.2, even the latter got LTS

    A bit of agreeable but I would argue that most of asset we have in unity are completely separatable from changing build system anyway. Some that do are most likely the automate script that might have alternative in dotnet and/or xamarin

    And if we launch the new format at first. After a while it become solid and old project system would be deprecated, we can then making conversion to amend it like unity always do
     
  41. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    What breaking changes did you consider?

    What comes to my mind:

    • For regular c# code most folks write it should not mean any breaking change.
    • Code relying on runtime specifics do need to be updated (build post processors for IL2CPP which emit IL maybe?) but that is to be expected on other runtime specific changes, so it is'nt really different from you current yearly lts updates.
    • Stuff relying on the current project system: csproj placements, asmdef manipulation, csproj manipulation, stuff like this would just right out break, but theese usually are to solve the shortcomings of the c# project system unity uses, and most of it would just become not needed anymore, becouse you can version the csproj and sln files.
    • UPM packages maybe? I mean I understand the reasons behind it, but you could create a mechanism which converts them to nuget packages. Also I understand how it might be more desirable to use UPM pacakages when you want to share many, big files (textures, meshes, etc), but if you would add nuget support code-only UPM packages would just make more sense to migrate to nuget.
    So, I specifically can't see the blocking issues you mentined? Am I way off? What problems did you consider?

    (Also I understand you might not be able to share any of the details I asked, but just a hot-warm-antarctic like answer would mean a lot to me, and potentially the community)
     
  42. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    There are two breaking changes which concern us with a move to .NET 6.
    • The .NET Framework ecosystem is based on mscorlib.dll - every assembly references that. In the .NET Core/5/6 ecosystem, that assembly does not exist. So any assembly compiled against mscorlib.dll or UnityEngine.dll or UnityEditor.dll will not work in the .NET 6 ecosystem. We see many projects that use pre-built assemblies, so this will be an issue for those projects.
    • The .NET 6 class libraries and runtimes don't support domain reloading. This concept exists in .NET Framework, and is the basis for the implementation of "Play Mode" in the Unity Editor. There are alternatives, like Assembly Load Context in .NET 6, but the behavior and expectations are different enough that we expect the lack of domain reloading to cause most projects to fail without some user modification.
    Internally as well we have many small assumptions about .NET Framework that add up to take time to address.

    I'll mention each of the things you brought up specifically:

    Correct, I expect C# script code to work without any changes.

    Right, I don't think this is an issue as well.

    I don't expect .NET 6 to change the way the Unity project system works, so I don't believe this will be an issue.

    I think that UPM packages will be ok, as they are all delivered as C# source code.

    I hope this helps shed some light on things. We're still working out a way to better communicate progress in an ongoing way.
     
    ModLunar, Thaina, Anthiese and 4 others like this.
  43. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Do you know why people use prebuilt dlls? My guess would be because using Nuget packages and internal dependencies in unity is attthe moment is not a trivial task, and really cumbersome - becouse it does not utilizes the standard dotnet build system. If you would make that work, people would not need to use pre-built dlls, they could just use their dependencies as package/project references, and this also would make life easier for them.

    On the load context: net 6 has preview on hot reload, wouldn't that make more sense than a custom system? Also couldn't you create an emulated version of the old system with a deprecation warning and phase it out a year later?
     
  44. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
    Correct me if I'm wrong, but I believe this could be solved by Unity shipping a compatibility mscorlib.dll which contains type forwarders leading to netstandard.dll or System.Private.CoreLib.dll.
     
    Thaina and Huszky like this.
  45. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm not sure about all of the reasons. At the very least, I think that some libraries are only distributed as pre-built assemblies.

    I know there is some work going on about better integration with Nuget, although I'm not entirely sure about the status of that work. I do know that we don't plan to tie .NET updates to Nuget support. Those two things are orthogonal to each other.

    .NET 6 hot reload is something we have looked at. At the moment it does not provide enough features, but it is still in development at Microsoft, so maybe we can help to shape it. I think that Assembly Load Context is closer to what we need. However, both are fundamentally cooperative - they require the code that is to be unloaded and reloaded to behavior properly.

    Domain reloading is not cooperative - it can force managed code threads to abort, so it places fewer requirements on the code to be reloaded. In our tests, nearly every non-trivial Unity project has some code that will need to be changed to work in a world where domain reloading does not exist.

    We have considered re-implementing or emulating domain reload, and that might be the direction we take. Unfortunately it is really a pervasive concept that touches lots of code all throughout the runtime. So re-implementing it is not a trivial task.
     
  46. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    109
    Thanks for the in-depth replies!
     
    ModLunar, JoshPeterson and NotaNaN like this.
  47. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    This is something we have considered, and yet decide to do. Unfortunately mscorlib.dll has a pretty large API surface, much more than System.Private.CoreLib.dll, for example. So the forwarders would be split across multiple assemblies. It would be complex, but possible.

    Microsoft did not choose to do this, so I'm not sure yet if it is worthwhile. It is certainly an option though to ease the transition.
     
  48. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,340
    Compilation speed is one reason - prebuilt dll's does not need to be compiled. Asmdef juggling solves the same problem, but may or may not be more complex to handle.

    There's also a bunch of stuff that's generally distributed as dll's that's used in a lot of places. The Steam integration is a good example - every Steam game would have to have their Steam dll swapped.

    Won't projects that support fast enter play mode not need to change, since fast enter play mode already requires you to handle the domain not reloading?
     
    ModLunar and NotaNaN like this.
  49. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Correct, I think these projects will be safe. But many project don't work with fast enter play mode.
     
    Andresmonte, NotaNaN and De-Panther like this.
  50. VolodymyrBS

    VolodymyrBS

    Joined:
    May 15, 2019
    Posts:
    150
    I'm not sure if this is really true. Correct me if I'm wrong.

    .NET Core (at least from version 2.1) and .NET 5 includes mscorlib.dll. It has just forwarded types to other assemblies (not just System.Private.CoreLib.dll).

    You even can use dlls compiled for .Net Framework in .NET Core app as long as they do not use some types that do not exist in .NET Core (and does not have type forward in mscorlib.dll)

    Here some info about how its work
    https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-framework-compatibility-mode
    https://docs.microsoft.com/en-us/do...d-party-deps#net-framework-compatibility-mode
     
    ModLunar, Knil and Thaina like this.