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

Unity Future .NET Development Status

Discussion in 'Experimental Scripting Previews' started by JoshPeterson, Apr 13, 2021.

  1. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    Oh crap, I forgot about that :/
     
  2. DrummerB

    DrummerB

    Joined:
    Dec 19, 2013
    Posts:
    135
    While that's cleaner, the IsNullOrX is more consistent with other APIs. And a static method would be more consistent with methods like Destroy(obj) and Instantiate(obj)
     
  3. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    @DrummerB Static method like Destroy and Instantiate may only work in MonoBehaviour or else it need to be referenced with class name, and that would make inconsistence code when people start making helper class

    Extension method can be copied anywhere
     
  4. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    I'd prefer both:
    1. Instance method (not extension method, maybe property if fast) gameObject.IsDestroyed() — like normal OOP.
    2. Static method (not extension method) GameObject.IsNullOrDestroyed(gameObject) — like conventional string.IsNullOrEmpty(s).

    No more implicit conversions, please.

    3. Maybe also null-checking extension method gameObject.AliveOrDefault() which “converts” dead object to real null so it can then participate in null coalescing ?? or Elvis ?. — similar to FirstOrDefault() from Linq.
     
    Ramobo, Knil and NotaNaN like this.
  5. LVermeulen

    LVermeulen

    Joined:
    Jun 26, 2013
    Posts:
    40
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Correct, assembly load context requires cooperation of the code to be unloaded. We're not quite sure yet how this will work in the end, but we are working on it.
     
  7. PerfidiousLeaf

    PerfidiousLeaf

    Joined:
    Aug 30, 2019
    Posts:
    20
    So, as far as I understand, they're pushing for "Hot Reload Everything" functionality in NET 6 starting with Preview 3 supporting ASP.NET and Blazor primarily: Announcing .NET 6 Preview 3 | .NET Blog (microsoft.com) . Right now it's just web pages but they expressed the desire to make this work for the live IL as well.

    If this feature was expanded, would it be another avenue to achieving the required functionality? If so, what primarily would need to be added to it for it to work? Considering that Microsoft seems committed to helping Unity (at least in so far as expanding the influence of .NET for their own benefit), do you think they would be willing to put some weight behind making the .NET ecosystem work with Unity?

    Also, your commitment to being transparent in this thread is being rewarded :) ; Unity Game Platform Details Plans for .NET and C# -- Visual Studio Magazine
     
    Last edited: Apr 27, 2021
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    The "Hot Reload Everything" feature is definitely something we have been looking into, but we don't have enough details yet to really understand if it will be a feasible solution for the Unity Editor. I'll try to update this thread if we come up with anything, but I don't expect to know about it soon.
     
    Tanner555, JesOb and NotaNaN like this.
  9. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    Im not sure if the hot reload feature that ms provides with .NET 6 is suitable for the cases that Unity developers end up in. From the blog post they mention that not all code edits are supported, and it links to this page and it looks very very limiting. The .NET team would have to collaborate a lot with Unity on making the hot reload capabilities more open, not to mention that its aimed for blazor for now, so I feel like the effort to pull that off is better saved on shaping the assembly load contexts more as it seems more promising.
     
  10. PerfidiousLeaf

    PerfidiousLeaf

    Joined:
    Aug 30, 2019
    Posts:
    20
    That's how it is now. Many .NET features evolved from a combination of desktop WinForms apps and older ASP technologies. Sure, there's much more in .NET now, including for game development. However, most features coming to .NET are not aimed at game development, they're aimed for business and enterprise. They also said their intention is to expand hot reload to support more than it does now. That's why I mentioned if Microsoft had any intentions of expanding their focus towards Unity in this regard.

    Anywho, we'll just have to wait and see how it develops.
     
    NotaNaN likes this.
  11. adabru

    adabru

    Joined:
    Jan 19, 2016
    Posts:
    3
    Here you go: https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Bluetooth

    UWP APIs can normally be called from non-UWP applications¹. But, at least half a year ago, this is not possible with the Unity Editor or the Windows Standalone Build. And e.g. the Arduino Bluetooth Plugin² doesn't support BLE on Windows Standalone or in the Windows Unity Editor while it does support it on the UWP Build.
    As workaround you can import dlls for BLE support. Exposing the above linked Bluetooth API would enable using Window's provided Bluetooth API without detours.

    ¹ https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance
    ² https://assetstore.unity.com/packages/tools/input-management/arduino-bluetooth-plugin-98960
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Thanks for these details. The specifics here are beyond my knowledge, but it might be worth raising with our Windows team in a separate thread on the Windows section of the forums.
     
  13. orangetech

    orangetech

    Joined:
    Sep 30, 2017
    Posts:
    50
    Happy to hear your guys exciting plan.
    I installed unity 2021.2.a15,
    Code (CSharp):
    1. error CS0246: The type or namespace name 'Span<>' could not be found (are you missing a using directive or an assembly reference?)
    span still not found. how to use "Span<>"?
     
  14. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    Monoupgrade is not yet in the current alpha, I think that would be announced here.
     
  15. JamesNK

    JamesNK

    Joined:
    May 5, 2021
    Posts:
    2
    @JoshPeterson I'm working on gRPC in .NET and a common user of gRPC are video games. Right now the Grpc.Net.Client library doesn't work on Unity because Unity doesn't support HTTP/2 with HttpClient.

    Will the improvements you talked about include supporting SocketsHttpHandler and its HTTP/2 support? That will unlock gRPC usage on Unity.
     
    Last edited: May 5, 2021
  16. MarekLg

    MarekLg

    Joined:
    Jan 31, 2018
    Posts:
    26
    Seeing a thread like this is really exciting me to work with Unity as a tool in the future. Would it be possible to start a thread on the above subject with the team working on it?
    This is by far my biggest pet peeve and I hope I'm not alone on this.

    Nevertheless, many thanks to your work! It is greatly Appreciated.
     
    Knil likes this.
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Support for .NET Standard 2.1 APIs (like Span)is not shipping in any Unity build yet. We're working on it now, and I'll announce on this thread when it is shipping.
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm not familiar enough with HTTP/2 to say. When did the .NET class library code in SocketsHttpHandler gain HTTP/2 support? Did that happen at .NET 5?
     
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    Yes, please feel free to start a separate thread for this!
     
  20. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
    HTTP/2 support shipped with .NET Core 3.0 I believe. Preliminary support for HTTP/3 shipped with .NET 5.
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I would expect Unity to pick it up then when .NET 5 or 6 is supported, although I'm not sure about the details of the implementation, so I can't say for sure that it will be supported on all platforms.
     
  22. TieSKey

    TieSKey

    Joined:
    Apr 14, 2011
    Posts:
    226
    U can use gRPC in unity by adding native libraries (at least on PC). I'm using the code first protobuf-net layer on top which handles the dependencies and wraps the entry points so I'm not sure if u need it or not but definitely possible.
    You can find that project in github,
     
    solarisn likes this.
  23. jihiggins

    jihiggins

    Joined:
    Feb 15, 2017
    Posts:
    1
    Does the mono update include updating the GC implementation being used? Or would that be a separate step?
     
  24. JamesNK

    JamesNK

    Joined:
    May 5, 2021
    Posts:
    2
    @TieSKey There are plans to deprecate Grpc.Core which wraps the native implementation. Blog post with details: The future of gRPC in C# belongs to grpc-dotnet

    That will leave grpc-dotnet as the gRPC client for .NET apps. For grpc-dotnet to work on Unity it will require HTTP/2 support in the underlying Unity implementation. That means it will need SocketsHttpHandler to be supported by Unity.
     
    Last edited: May 6, 2021
  25. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    It does not include a change to the GC. We expect that changing to use CoreCLR as the JIT engine will involved a change to use the CoreCLR GC, but we don't expect to change the GC prior to that.
     
    jihiggins likes this.
  26. TieSKey

    TieSKey

    Joined:
    Apr 14, 2011
    Posts:
    226
    Oh, interesting. Well, it doesn't matter much for me but I can see how it's a serious impediment for companies looking to start a new project right now.
     
  27. MarekLg

    MarekLg

    Joined:
    Jan 31, 2018
    Posts:
    26
    Sorry to get off topic for (hopefully) the last time.

    I created said thread here and hope that you could get it the attention of some people from the Unity Team.
    Also, to the users already commented on the '==' operator overload problem: please comment and discuss to give this thread some momentum and tell what I missed or should change over there.

    Thank you!
     
  28. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    A quick update on our progress:

    The first item in my original post "Update Unity’s fork of Mono to the latest code from the upstream Mono repo" has landed internally now. It will appear in the upcoming public Unity release 2021.2.0a18.

    This work doesn't have user-facing changes (outside of bug fixes), but it does lay the foundation for much of the other work I mentioned.

    I'll continue to update that original post and this thread with details as we know when other parts will land.
     
  29. SonicBloomEric

    SonicBloomEric

    Joined:
    Sep 11, 2014
    Posts:
    1,090
    I think I speak for everyone here that this is very much appreciated.
     
  30. PerfidiousLeaf

    PerfidiousLeaf

    Joined:
    Aug 30, 2019
    Posts:
    20
    I've been curious, is it possible for Unity to make use of Native AOT (CoreRT) for native code gen purposes (alternative to IL2CPP)? dotnet/runtimelab at feature/NativeAOT (github.com)

    The tl;dr is it basically takes the IL from RyuJIT and translates it to native code for the target platform. it's intended for usages where CoreCLR or other VMs aren't allowed/won't work.

    This would be of course after Unity has moved to CoreCLR as a runtime.
     
    Last edited: May 22, 2021
    Ramobo likes this.
  31. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    @Peter77, changed your mind about the benchmarks?
     
    Peter77 likes this.
  32. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    Not really, but I can run the benchmark and post results if these changes are expected to affect performance. Would be interesting to see if and how much.
     
    Ramobo likes this.
  33. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    If there's no noticeable difference, then Unity seriously f♥♥♥ed up the fork update, because newer versions of Mono are indeed faster.
     
  34. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,620
    I guess we'll find out next weekend :)
     
  35. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    We have not investigated CoreRT yet, although we may. It is certainly a very interesting project.
     
    Tanner555, Thaina and JoNax97 like this.
  36. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Last edited: Jun 5, 2021
    Tanner555, NotaNaN, Knil and 2 others like this.
  37. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    It's nice that fp got hot reloading into gmod2 but I wonder what kind (it looks like regular EnC because html and their css files are also auto updating) because the one introduced by .NET 5 and 6 are based on EnC which have limitations as stated here roslyn/EnC-Supported-Edits.md at main · dotnet/roslyn (github.com). I still have doubts that the live hot reloading that MS provides is sufficient for the cases that programmers in Unity are used to and will expect. Though I could see it being a separate feature that can be enabled the same way that domain reload on play can be disabled, something that the Visual Studio package team will have to handle.

    Also just an interesting fact, garry was given access to the source 2 repo by valve directly and fp ended up adding a lot of ux and later on c# support for end user modding in their own copy of source 2 for their gmod2 project (s&box)
     
    Tanner555 and Elringus like this.
  38. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Yes but they are "working to expand the set of supported edits". For me being able to just change method body would be really helpful.
    I wish they'd do it for Unreal instead. Not sure if C# is the best idea for modding as it won't compile dynamically on all platforms but I guess they target Windows.
     
  39. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    I'm happy to report that default interface methods support is in Mono and IL2CPP is in Unity 2021.2.0a21.
     
  40. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    Does that mean that .NET Standard 2.1/Framework 4.8.x is also available? Or will that come later?
     
    Tanner555, Qbit86, NotaNaN and 2 others like this.
  41. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,938
    No, not yet. Those changes are ready on our side, but not yet landed in a release. I'll be working on doing that today - but I can't say yet when they will be through final testing.
     
    Anthiese, djsell, gtk2k and 15 others like this.
  42. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
    This is very exciting news! Looking forward to being able to remove System.Memory.dll from my projects.
     
    Anthiese, andywatts, Qbit86 and 3 others like this.
  43. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    @JoshPeterson I just want to say: thanks for keeping everyone here updated on your progress.
    This stuff is super important to a lot of us, and with Unity being closed source there's often no way for users to get any development info. Your team is doing a great job in that regard.
     
    Wattosan, orangetech, foonix and 21 others like this.
  44. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    On a side note, a more aggressive variant of this concept could be a c# interpreter in editor only (but compiled when built). This would allow for 0 second iteration times, I'm actually looking into this since I got lua integrated in one project and the development is stupid quick.
     
  45. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    In editor you can do that with visual scripting, Bolt doesn't compile to c# but this does https://assetstore.unity.com/packages/tools/visual-scripting/unode-visual-scripting-101176.

    I'm looking for interpreter that would also work in run-time on all platforms for modding but I don't think it exists.
     
  46. lmakor

    lmakor

    Joined:
    Oct 31, 2016
    Posts:
    23
    @JoshPeterson that is great news!
    Thank you and your team for all the work you are doing!

    Assuming C#9 support won't make it into the 2021.2 release cycle (and thus not into 2021 LTS) would it still be possible to use C#9 function pointers in Unity?
    I heard that C#9 function pointers don't require new/additional runtime support and thus should work in Unity.
    However, I have yet to find out how one would use them in Unity.
     
  47. Lhawika

    Lhawika

    Joined:
    May 27, 2015
    Posts:
    53
    Function pointers are already present in the current alpha. There was a bug which silently crashed the editor, but it is supossed to have been fixed since the issue was repported.
    I did not have time to test the fix myself, though.
     
    Tanner555 and phobos2077 like this.
  48. Kirsche

    Kirsche

    Joined:
    Apr 14, 2015
    Posts:
    121
    Kamyker likes this.
  49. PerfidiousLeaf

    PerfidiousLeaf

    Joined:
    Aug 30, 2019
    Posts:
    20
    Also, this is even already supported in basic under .NET Core. It's used in Web Dev where we modify Route Controllers during live testing. The limitation right now is simple method edits but MS is expanding this function. Unity will eventually get this I assume, we'll see.
     
  50. donovanstrawhacker5

    donovanstrawhacker5

    Joined:
    May 13, 2020
    Posts:
    2
    Its definitely better than it was before especially now that they arent compiling base every time. Hotreloading has opened my eyes and now restarting feels clunky