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. Dismiss Notice

Unity Future .NET Development Status

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

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,844
    Can we use MS' own JSON in Unity 2021.2 Beta?
     
  2. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    289
    We can, if these dependencies work in 2021.2

    Microsoft.Bcl.AsyncInterfaces
    System.Buffers
    System.Memory
    System.Numerics.Vectors
    System.Runtime.CompilerServices.Unsafe
    System.Text.Encodings.Web
    System.Threading.Tasks.Extensions
     
    Thaina likes this.
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Can you submit us a bug report for this issue? I've not seen this error before, and I would like to investigate it more. Thanks!

    https://unity3d.com/unity/qa/bug-reporting
     
  4. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,844
    I guess not then :(
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Unity 2021.2 supports .NET Standard 2.1, so I believe that all of those dependencies should work. Do you find that they do not?
     
    Laicasaane likes this.
  6. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    289
    I said so because I didn't have time to test it myself, sorry if my words confused you.
     
  7. aizuon

    aizuon

    Joined:
    Jun 24, 2014
    Posts:
    7
    System.Runtime.CompilerServices.Unsafe is not included in my case. Unable to use messagepack unless i download the dependency binary and put it in the plugins folder
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    This is the expected behavior. The System.Runtime.CompilerServices.Unsafe APIs are not a part of .NET Standard 2.1. They appeared in .NET 5. They can work with .NET Standard 2.1 when provided as a separate assembly. See https://apisof.net/catalog/2afb814f-9d0f-a308-2918-c34682c2806b for details.
     
    aizuon likes this.
  9. oxysofts

    oxysofts

    Joined:
    Dec 17, 2015
    Posts:
    124
    Hello! Sorry if it's been discussed already, but I see that .net 6 has new infrastructure for more advanced hot reload. JetBrains Rider has rolled out support in its EAP and Visual Studio will have it as well. Will it ever be possible to take advantage of this in Unity? Being able to make a code change in some function and seeing changes in-game in less than a second without recompiling or domain reload would be an actual gamebreaker, iteration speed alone would raise by several orders of magnitude. Game development is so much about guesswork, a lot of the time you don't know how the code is gonna feel until you try it.
     
    FernandoMK likes this.
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    We don't plan to have .NET 6 Hot Reload support in Unity now. Although it is faster than Unity's current domain reload solution, it is also much more limited about what code changes can actually be supported.

    Since domain reload does not exist in .NET 5 and later, we're actively working with Microsoft to come up with a code reloading solution that both works with Unity's existing workflows and is faster. We'll be able to share more about that in the future. Details are too uncertain now though.
     
  11. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    Hot reload also doesn't break whole project during gameplay. It seems to me that it's very different usecase than domain reload. Both should be supported just like in Unreal (recompile and live coding).
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Yeah, this is where I think we want to be long term. There are different use cases. At the moment, our focus for a .NET Core-based Unity is to keep existing projects working as much as possible, which means having something like domain reload.
     
  13. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Is there not a way to auto convert existing code project to the new code? like unity does with the script updater
     
  14. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    I understand that I know nothing about hosting mono or .net Core in native app but.

    Why full kill and deallocate all managed host memory and create new one from scratch (instead of domain reload) is not an option?
     
  15. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    I doubt that is possible. We're really talking about run time behavior of code here (e.g. native backgrounds threads). So static analysis to convert code is pretty difficult.
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Yeah, that is certainly an option. So far in our exploration that does not work well with CoreCLR, and may in fact be slower than domain reload. But we're looking at a number of possibilities.
     
  17. VolodymyrBS

    VolodymyrBS

    Joined:
    May 15, 2019
    Posts:
    150
    Hi, @JoshPeterson
    is there any chanse to get C#10 in 2021.3?
    It will be released on 9th of November that just 2 weeks after Unity 2021.2 release.
    Most of features in this release are just syntax sugar and some of them could be quite useful.
    And according to my tests most of them works in Unity 20212
     
  18. Mindstyler

    Mindstyler

    Joined:
    Aug 29, 2017
    Posts:
    224
    unlikely
     
    VolodymyrBS likes this.
  19. VolodymyrBS

    VolodymyrBS

    Joined:
    May 15, 2019
    Posts:
    150
    but still, everything is possible ;)
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    No, we don't plan to add C# 10 support in the 2021 series. Generally the .3 release of a given series is the LTS version. We don't add many new features that are not already in the .2 version.
     
    Tanner555, foonix, NotaNaN and 2 others like this.
  21. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    106
    Does 2021.2.0 support source generators? I could not find it in the release notes.
     
  22. Mindstyler

    Mindstyler

    Joined:
    Aug 29, 2017
    Posts:
    224
    It does.
     
    Huszky likes this.
  23. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    548
    A more abt answer would be: it does... but you gotta set it up yourself with external libraries and messing about in your configuration. Go to page 6 to read more about it, and let me know if you understand what they're talking about XP
     
  24. adamhill

    adamhill

    Joined:
    May 30, 2008
    Posts:
    26
    Note: @neucc (of UniRx fame) has an implementation of MessagePack for Unity ready to go.
     
    aizuon likes this.
  25. galbartouv

    galbartouv

    Joined:
    Dec 6, 2015
    Posts:
    7
    As far as i can tell the default interface isnt working.
    on the one hand i dont get error in the interface itself, but when a class implements the interface it thinks the default implementation doesn't exist
     

    Attached Files:

  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Can you submit a bug report? We have tests that cover pretty much this exact scenario, so I'm surprised that it does not work. Maybe there is some subtle case we are missing.
     
  27. galbartouv

    galbartouv

    Joined:
    Dec 6, 2015
    Posts:
    7
    sure, on it
     
  28. galbartouv

    galbartouv

    Joined:
    Dec 6, 2015
    Posts:
    7
    i have never submited a bug report before... how do i do it? cant seem to find where to submit
     
  29. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    Have you ever heard of Google? Try: "how to submit bug report unity".
     
  30. galbartouv

    galbartouv

    Joined:
    Dec 6, 2015
    Posts:
    7
    I have heard of Google, thank you. I hope your day is as pleasant as you are.
     
    Trigve and NotaNaN like this.
  31. VolodymyrBS

    VolodymyrBS

    Joined:
    May 15, 2019
    Posts:
    150
    it's not a bug.
    it's how Default Interface Methods works.

    classes do not inherit default implementation.
    DIM available only when you work with object of interface type

    So in your code you need to change OnClick to something like this
    Code (CSharp):
    1. public void OnClick()
    2. {
    3.     ((ISingleClickable)this). OnBla() ;
    4. }
    or just do not abuse DIM for thinks like this:p
     
  32. galbartouv

    galbartouv

    Joined:
    Dec 6, 2015
    Posts:
    7
    oh thx that worked :)
    why do would call this abuse though, isnt this the point of DIM?
     
  33. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    258
    DIMs are intended to allow interfaces to be extended later without breaking existing implementations of them.
     
    galbartouv and VolodymyrBS like this.
  34. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,049
    Point of interface in general is you can use interface as type of argument and variable instead of specific class or struct, especially with generic. That is the topmost functionality of interface

    DIM is just a feature that try to make that functionality more useful, what I see you really want to do is extension method
     
    galbartouv likes this.
  35. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    In your case, an abstract class would actually make more sense, and you would have behaved as you would expect. The reason why DII works so is because you can implement several interfaces, and as potentially the same method could have a default implementation several times, so you have to specify which interface you are using. And if the class doesn't implement the interface, naturally you have an error. In the .NET world, interface-only development is often used, which means that many APIs only work with the interfaces and never with the implementation themselves, so the problem does not exist.
     
    galbartouv likes this.
  36. galbartouv

    galbartouv

    Joined:
    Dec 6, 2015
    Posts:
    7
    i honestly just wanted to try to use this functionality to have multiple inherence which i understand is kind of hacking the purpose of this feature. With multiple inheritance i can create a composition of functionality and avoid some of the issues the single inheritance causes.
     
  37. nra

    nra

    Joined:
    Dec 16, 2013
    Posts:
    8
    Just wanted to chime in and say I am stoked to see such transparency !
    This thread made my day.

    I hope Unity can incorporate this into all its development.
     
  38. Scoth_

    Scoth_

    Joined:
    May 25, 2020
    Posts:
    9
    If DOTS had this transparency it would be amazing, as it doesn't, it seems like everything is dead and lost.
     
  39. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    PHP also only has single inheritance, but has a solution with traits, whose content is simply copied into the target class during parsing. (However, if used incorrectly, this can quickly lead to problems).

    Default interface implementation as a replacement for traits is a bit safer, but if you use it you have to know how default implementation works, especially when properties come into play. For example, if you have two interfaces that have the same property, they are two different implementations, a class that uses these two interfaces and also implements the property, then there is the property 3 times. The default implementation would only ever use their own default implementation.
     
  40. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    106
  41. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    We're really excited to see NativeAOT move toward a becoming a supported code generation option in the .NET ecosystem, since many platforms Unity supports do not allow JIT. IL2CPP is a mature technology which works across all of those AOT platforms Unity supports, so we don't plan to replace it anytime soon. We do plan to work with Microsoft on .NET technology across the board, including NativeAOT. Both NativeAOT and IL2CPP are solving similar problems, so there is plenty of room to learn and grow.
     
  42. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    Worth saying that NativeAOT can be used in Unity by simply compiling library for a platform. Very useful for stuff not supported in IL2CPP like System.Process.
     
    Walter_Hulsebos and Thaina like this.
  43. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,049
    That's really a good thing. I wish microsoft would just making C# project that will automatically integrate unity as a library soon
     
    CaseyHofland and JesOb like this.
  44. Lymdun

    Lymdun

    Joined:
    Jan 1, 2017
    Posts:
    46
  45. Huszky

    Huszky

    Joined:
    Mar 25, 2018
    Posts:
    106
    @JoshPeterson does this mean that work has started to move to .NET 6?
     
  46. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Yes! We'll have more communication to come soon with additional details (we're still working some things out internally). But we've started to work on getting CoreCLR to work as a JIT runtime in Unity.
     
    stonstad, Nad_B, Wattosan and 33 others like this.
  47. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    CoreCLR as a JIT meaning RyuJIT? Meaning we get recompiling hot methods, inlining virtual calls, etc? That might be the single greatest improvement to performance that Unity could make right now.

    Every user script, all the "glue" setup for ECS/Burst that's done in managed, dependency injection/interface-first OOP, every editor extension on the asset store, UI Toolkit and UGUI, tweens, coroutines, and all the "death by a thousand cuts" when you have tons of miscellaneous scripts running in your game...

    If this is really happening I'm flabbergasted.
     
  48. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Yes, this is what we are aiming for.
     
    Nad_B, PutridEx, OndrejP and 14 others like this.
  49. WinterboltGames

    WinterboltGames

    Joined:
    Jul 27, 2016
    Posts:
    257
    Does this also mean C# 9 or possibly 10 support?
     
  50. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,771
    Yes, we plan to keep up with C# language and run time support as we move through the process of migrating Unity to a .NET Core-based ecosystem. I'm not sure yet what versions of Unity will have which C# language support so I can't give those details.