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 5 and Mono Runtime

Discussion in 'General Discussion' started by Deleted User, Mar 19, 2014.

  1. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Can someone specify that? I've never had any problems with monodevelop..
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I fear that's also wrong :)
    Unity's MonoDevelop sucks is more accurate, because MonoDevelop itself works a lot better at least for me.
     
  3. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Unity's MonoDevelop will be fine as a simple code editor. Unless you want to debug Unity with, then you'll start to see all the problems people are talking about. Even without debuging, it's buggy as hell.
     
    Last edited: Apr 2, 2014
  4. minionnz

    minionnz

    Joined:
    Jan 29, 2013
    Posts:
    391
    This is the most annoying thing IMO (affcts VS as well)- I wish I could add new class library projects to the solution, but they keep disappearing on me.
     
  5. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
  6. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    I don't really understand how this new thing they've released is different to NGEN. It goes straight from the C# source and so is better able to optimise, I guess?
     
  7. minionnz

    minionnz

    Joined:
    Jan 29, 2013
    Posts:
    391
    I believe the main difference is that NGEN still has a dependency on the .NET framework while .NET Native doesn't (the app is fully self-contained, no framework required). At least that's what I've been able to gather from what I've read so far.

    I wonder how this is going to affect Mono? .NET is no longer required on the deployed device.
     
  8. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    This is really awesome. I'm still watching the video but it looks like it applies to any .net based application, straight into machine code.
     
  9. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    It wouldn't work with Unity at the moment because Unity relies heavily on reflection for just about everything. It's good for mobile games that want to eke out more performance but I don't think it's a big game changer overall. People need to realize that there is a reason that .NET does things the way it does, and it's not just to purposefully make things slower than C++. JIT and a unified IL provide benefits that you can't get with a native statically linked executable.
     
  10. Astfgl

    Astfgl

    Joined:
    Jan 19, 2014
    Posts:
    86
    Native compilation does not preclude the use of reflection. Reflection is just a bunch of compile-time generated metadata that's included in the assembly. COM had reflection too, and that's as native as you can get. The only difference is that with COM you had to follow a set of coding patterns to manually add the reflection info, while with .NET you get reflection for free.

    The one thing you cannot do with a natively compiled app is run-time code generation, which requires the presence of an interpreter or a JIT compiler. It's the same limitation you already have on iOS because of its ahead-of-time compilation.
     
  11. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    If you read the link, you will see that it does not work well with reflection currently.
     
  12. Astfgl

    Astfgl

    Joined:
    Jan 19, 2014
    Posts:
    86
    That's not what I read:

    So there are "some" limitations, but it doesn't specify exactly what those are. However, reflection is supported and if most applications are expected to "just work", then I would think most reflection functionality does actually work.
     
  13. cynic

    cynic

    Joined:
    May 21, 2013
    Posts:
    142
    Well, this is certainly very interesting. For now it seems MS limits this to Windows Store apps. Let's see how long it will take them to bring this to Desktops.
    Most importantly however, let's see whether this technology actually comes to the other mobile platforms (iOS and Android) and how this might be integrated by Xamarin or whomever, considering lots of Unity users are actually not developing on Windows.
     
  14. Astfgl

    Astfgl

    Joined:
    Jan 19, 2014
    Posts:
    86
    Yeah, I wouldn't hold my breath for this to be available for any other platform than Windows, let alone Unity's version of Mono.
     
  15. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    862
    If you listen to the talk they say that .net native uses the .net garbage collector. This just takes optimization to a whole nother level but does not remove the need for mono and its updated GC.

    Unity should partner with Xamarin and develop something like this for Mono. I hope that is what Miguel was hinting at. Right now unity does not seem to have contributed anything useful to the Mono project. I could see how that would be annoying since they are both almost direct competitor in the cross platform market.
     
    Last edited: Apr 3, 2014
  16. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    If I remember correctly, Xamarin is already working on it. Heard it in a podcast, I believe it was that one:
    http://www.imore.com/debug-31-miguel-de-icaza-mono
     
  17. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    I see. Is that really so valuable these days? I mean, they've deployed .NET Framework updates via Windows Update - I thought the install base was pretty high, so I don't see any significant harm in having a dependency on it...
     
  18. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    FYI, Microsoft just open sourced their new .NET compiler (Roslyn).
     
  19. Nasarius

    Nasarius

    Joined:
    Oct 1, 2012
    Posts:
    17
    Yeah, that's very interesting. Unfortunately it's only one out of three necessary components; you also need the JIT and the framework to actually run C# code.
     
  20. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    It's not about that. It's about performance. And apparently about start up performance in particular. They are saying that some applications are seeing their start-up times improved by several seconds. That's a huge a deal I think.
     
  21. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    There's a whole chapter on it in the documentation: http://msdn.microsoft.com/en-us/library/dn600640(v=vs.110).aspx

    Read specifically the "plugins that use reflection" (which Unity does), and the parts about needing to manually import classes via metadata. I don't think there would be a way to get something like Unity's SendMessage to work, since they probably just scan through method names for a string without knowing anything about type.
     
  22. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    It would be particularly valuable if they made a version for iOS, because the entire reason that Unity can't update Mono is because iOS requires static linking, and that's where Xamarin has them trapped on Mono license issues. If it wasn't for iOS, Unity would be able to update Mono for free without paying Xamarin a dime. But because iOS requires static linking of the .NET Framework, it violates the LGPL and Unity needs to pay for a custom license. If Microsoft made a version of this for iOS (and made it legal to use for free, of course) then Unity would possibly have a way out of the worthless partnership with Xamarin that they're stuck in.

    But I'm not getting my hopes up that Microsoft will ever port this to iOS.
     
  23. minionnz

    minionnz

    Joined:
    Jan 29, 2013
    Posts:
    391
    I'll always hope :) Microsoft have been a lot more open in recent years and we know they're focused on getting developers into the Windows app platform. If they want to get people to develop for the Windows Phone, it makes sense to make it easy as possible for developers to convert their iOS/Android apps to WP. Not many developers are willing to invest time/money into Windows Store apps at the moment (at least not compared to iOS or Android), so providing a cross-platform toolkit (including .NET native) that works on all devices is what they need to do.
     
  24. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Yeah but MS is pretty schizophrenic about these things, since they have so many conflicting products and goals. They want to make the Windows Phone a more attractive dev platform for devs than iPhone and Android, which means they want to make it look faster and easier to develop for than the others. But they also want to get people to buy their dev tools like Visual Studio, which means they want to make them useful when developing on other platforms. I think MS's ideal position is being able to say "Yes, you can use our tools to develop for iPhone and Android, but your app will run even better on Windows Phone", and Native .NET fits into that slot pretty nicely.
     
  25. cynic

    cynic

    Joined:
    May 21, 2013
    Posts:
    142
    Let's really hope for this. I agree, that there is reason for hoping, given the new MS leadership. Historically the Enterprise and Cloud division has been more open than other departments at MS, heck you could even get Azure services base on Linux boxes, if you wanted to. Given, that they finally got their backsides off their hands and released Office for iOS, since it was ready a long time but held back due to old leadership politics, I'm quite confident in Microsoft actually realising where their strong points are and that they have more to offer than pushing their own operating system all the time.
     
  26. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    862
    You should watch the video that shaderop posted. They do more than just scan strings. They also allow manual hinting like the link you posted says.

    As long as the right types get included they can resolve them at run time.

    Including a few unneeded types is not the end of the world.
     
  27. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    You're awfully hopeful for a guy named cynic. ;)
     
  28. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I meant Unity SendMessage works by scanning strings, not .NET Native. Anyway, I'm tired of explaining this; if you guys want to believe you can just drop this right into Unity then go ahead, I'm not stopping you. :p
     
  29. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Theoretically if Unity would integrate .Net Native, we only would need to specify which methods may be called using SendMessage, Invoke, ... just to be sure they are not optimized away. Unity could define heuristics for all its methods that call others by string to automatically mark those called methods, such that they are preserved. There is no reason why it shouldn't work. It is pretty obvious that we can't integrate it, but Unity could do that. Sure, it would be Windows only, but from a technical point of view, this would work.
    In the video they draw a special xml file on the border which was introduced to define such methods, properties, fields, ... .
     
  30. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    862
    What do you mean works by scanning strings? It has to compare types at some point. I am not even sure that SendMessage uses Reflection.

    You are probably talking about something like this right.

    Code (csharp):
    1.  
    2. public static bool HasMethod(this object objectToCheck, string methodName, Type[] types)
    3. {
    4.     var type = objectToCheck.GetType(); // don’t need this var really
    5.     return type.GetMethod(methodName, types) != null;
    6. }
    7.  
    They said they are able to get the var right most of the time. I think in this case it would work fine, unless objectToCheck was a var itself. From what they said they can already handle most real world code. Realistically programming with var makes code maintenance harder anyway. Everything has to become a type at some point. It simple becomes a problem of addressing all the edge cases and compile time complexity.

    Also SendMessage feels like an ugly hack. I rarely use it although it can be useful in a few limited cases.
     
  31. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Um, what? Var is a bit of compiler sugar; it's always resolved at compile time. It's got nothing to do with runtime processes like reflection.
     
  32. TheOtherMonarch

    TheOtherMonarch

    Joined:
    Jul 28, 2012
    Posts:
    862
    Yes but how do you know what types to include. For cases where you don’t know at compile time, since the code is not JIT compiled anymore.

    The video covers Dynamic, var and object key words. The hinting seems to be really for libraries

    The video covers this from 32 - 39
     
  33. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
  34. Aphid

    Aphid

    Joined:
    Dec 16, 2013
    Posts:
    14
    There are no situations where you do not know the type of 'var' at compile time; if it can't be determined, you cannot use var. You get a compile error instead.
     
  35. TehWardy

    TehWardy

    Joined:
    Mar 20, 2013
    Posts:
    38
    Haha ... all that and still Unity confirms nothing!

    What do we know as FACT ...
    Unity have told us that they plan to somehow convert what we write in C# in to C++ likely through converting IL in to C++.
    Microsoft offers up an open source way to handle C# to IL compilation but also plans to offer up C# directly to native code.
    Microsoft is also interested in working with Unity (hense the UnityVS acquisition).
    This "extra step" converting IL to C++ is purely for supporting WebGL (apparently) at this time.
    Like others have said, Unity would be nuts at this point to drop the use of C# as a scripting language as it doesn't take much to find someone who clearly states "i'm here because I like using C# to write games".

    My thoughts ...
    To not support C# going forward feels like Unity commercial suicide to me (I have been wrong in the past though).

    If Unity are smart, they are probably in talks at a technical level with Microsoft about taking CLR code and through something like roslyn (possibly a custom build), then, being given all the tools they need to provide "native code" on any platform pretty much "out of the box" as per Microsoft's roadmap.

    As I see it ... to go from C# to native code does not require anything from Unity at all ... Microsoft have all this and are starting their drive to market this quite heavily, with that said Unity really only needs to support / work with roslyn for the purpose of debugging then do as they always have and live in the C++ / native world worrying about low level acrchitecture and linking in to these C# to native assemblies.

    Since Unity doesn't sit on .Net but instead sits on mono, my thinking is that there is a bit of "awww niiiice" going on over at xamarin right now as they no longer have to worry about compiler code they purely have to worry about programming mono framework.

    So surely everyone wins here?

    I just want that .Net 4.5 support in Unity ... something that Unity have yet to confirm ... it would make sense that this will happen because Unity don't actually have to implement any .Net functionality (as I see it) but who knows!
     
  36. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    384
    Any updates on this maybe? Can we expect anything for PC and Unity 5 in 2015 (especially that you are working on directx12 too) ?
     
  37. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Check the blog - several updates there regarding the future of scripting in unity.
     
    sqallpl likes this.
  38. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    384
    You are probably referencing to this post http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity/

    I'm just wondering if there is any chance to see any changes for pc in 2015. Some people on forums told that pc is not at the beginning of the list for these updates.
     
  39. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    IL2CPP will be rolled out on WebGL first, then iOS and once both of those are stable with zero bugs that can be found, it will be rolled out to other platforms, which may be a quicker procedure. WebGL and iOS kind of need it earlier due to restrictions on those platforms, so it makes sense.

    Once IL2CPP is seen to be stable, Unity can think about upgrading mono as they will have valid compatibility for difficult target platforms.

    As for time frame, that is up to the engineers at utech :)
     
    sqallpl likes this.
  40. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    384
    Good to know. Thanks for your reply!
     
  41. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I am most looking forward to some serious speed improvements and the IL2CPP code stripping, I mean it won't require having your source code hidden in there. I'm not sure it makes much difference in a world where you can get full source to almost anything, but I feel better about it :D

    Also if the GC magically becomes better then I won't be complaining about that either!
     
  42. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    394
    Sorry to necro this thread, but I could have sworn Unity mentioned using newer mono/C# (than 2.0) in Version 5.0. I still am using V4.6 and thinking of upgrading... getting some new C# stuff would be pretty attractive.

    Has this happened? Or not yet?

    -Carmine
     
  43. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,617
    I believe they mentioned moving to it some time in 5.x, not in 5.0. It requires moving more platforms to the IL2CPP scripting back end, and for now the focus is on platforms which require it for deployment (ie: iOS and WebGL).
     
  44. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Why is it the biggest naysayers have less than a few hundred posts? I make all kinds of complex tools in Unity and if I am doing it my way I use Unity js as I can write it like I write an email. Most of the stuff in this thread is high tech gobbledygook to me and I wake up daily and make money with this app. 6+ years now. There are transforms, vectors, arrays, quaternions, meshes, renderers, strings and various data types. I don't get all the hullabaloo. Sounds like some of you should just go work at a supercomputer complex or sumthin where ya can wave that high tech gobbletygook appendage about:). Good read though. I picked up a few new things I didn't know.
     
  45. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    According to the new road map, an upgraded Mono/.NET runtime is in the "research" phase, and it's going to be a very long time until it is integrated. That's disappointing.
     
  46. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    But this is not new information at all. They first of all have to bring il2cpp to all platforms that require AOT and maybe to some more and afterwards, they will have the possibility to upgrade Mono/.Net.
    Besides that, there has been some heavy development going on the the .Net world. They need to try out whether the newest developments are stable enough and suitable yet or not. So it is very much a research topic.
     
    angrypenguin likes this.
  47. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    I'm thinking an IL2CP to native build process could give faster improvements in performance on all platforms?

    GC should not be used in game and real time simulations look at Apple's GC replacement using ARC.
     
    darkhog likes this.
  48. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I think so too. But if they bring it to all platforms first, it will likely mean that the .Net version update needs to be delayed.

    If you want to discuss the GC, you should create a new thread. GCs are a required part of .Net, otherwise something new would need to be created which is not the topic of this thread.
     
  49. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    It's not new information that it was in research but the timeline for it has been made much clearer with the roadmap. We knew it would be dependant on IL2CPP. But upgrading to modern Mono was teased over a year ago http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity/ Maybe it was just wishful thinking but since it's been a year, and IL2CPP is getting close to working well on iOS, and it's been said that porting to new platforms is easy, it seemed like the Mono update was just around the corner.

    Now with this roadmap, it's clear that it is not a high priority and it will be at least another year, maybe 2 years... It's "new UI" all over again.
     
  50. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,897
    According to the roadmap a Mono upgrade is nearby.