|
Does unity support the C# keyword var and if not are there plans to support it? EDIT I did some research and found that mono seems to support three versions of C#: 1, 2 and 3. In 2007, they added support to C# 3 for the var keyword. I'm not sure what version of mono is being used in Unity and if it should support var (maybe I'm doing something wrong). Thanks! Solution As @The Stone and @Ricardo were nice enough to point out, Unity is currently supporting an older version of mono that doesn't yet support the C# 3 feature set (var, LINQ, etc). They are investigating it and would have implemented it with Unity 2.6, but it would break backwards compatibility. Currently there is a lot of interesting discussion in the user voice page for it so feel free to read about it/vote it up if it is important to you. Update Hey all, with the Unity 3.0 announcement and a pending release in Summer 2010 it looks like this feature will be implemented. I can't wait.
(comments are locked)
|
|
Unity does not use the latest version of mono. The latest version is 2.4 and 2.6 will be out soon, right now Unity uses an 1x version, they haven't upgraded due to doing so will break all existing web player games. But I guess they will do so when Unity 3.0 comes, I hope so at least. Thanks for the clarification. Its not the end of the world, but I'm with you. I really hope they update with version 3.0. I think I'll head over to user voice...
Nov 25 '09 at 04:45 PM
Michael La Voie
Aras mentioned on the feedback page they wanted to do it for 2.6, but had to delay it. There's no estimated deadline for it yet: http://feedback.unity3d.com/pages/15792-unity/suggestions/158233-scripting-upgrade-mono-to-2-4-2-6?ref=title
Nov 25 '09 at 05:12 PM
Ricardo
(comments are locked)
|
|
Here's a trick I am using to get C# 3.0 language support for var, extension methods, lambda expressions, object initializers, collection initializers, implicitly typed arrays, expression trees, auto implemented properties, and query expressions. I've only done this for Windows. The Mac instructions are probably analogous. Download and install the latest version of Mono (2.6.1) Copy these files: gmcs.exe, gmcs.exe.config From: C:\Program Files\Mono-2.6.1\lib\mono\2.0 To: \Unity\Editor\Data\MonoCompiler.framework This only works because C# 3.0 compiles into IL compatible with the 2.0 runtime. Though, linq to objects does require a change to System.Core (which came with .NET Framework 2.0 SP1)... but linq code compiles and runs fine for me, so I guess the version of mono that Unity is using includes this change. What definitely doesn't work is linq to sql, because that requires System.Data.Linq Holy moly! Thats brilliant, I'm sure it's not "officially" supported, but I'm going to try that out this weekend. If this works, you will have saved my butt. I'll come back and update once I've tested it. Thank you!
Dec 09 '09 at 06:37 AM
Michael La Voie
If I could downvote myself to vote you up more than once, I would. I can confirm this as working on OSX, even if the files you'll need to copy are slightly differently named. There's no mono.dll, and the libglib and libgmodule will have .dylib extensions. This will get you var declarations, collection initializers... the works.
Dec 09 '09 at 01:08 PM
Ricardo
To get this to work with Mono 2.6 you must copy the file libgthread-2.0-0.dll from the mono bin folder, too. Thanks for this "hack"!!
Mar 04 '10 at 12:08 PM
Froghut
whoops, you're right. and you don't need libgmodule-2.0.0.dll
Mar 05 '10 at 12:53 AM
Lance Sun
Update: If you are using LINQ in your project, it will work. If you are using a prebuilt assembly targeting .NET 3.5, and that assembly uses LINQ, you will get an error message in Unity about System.Func
Mar 05 '10 at 03:00 AM
Lance Sun
(comments are locked)
|
|
I posted an upgrade script here: http://github.com/LoganBarnett/unity-mono-upgrade It's for OS X only. Feel free to submit a Windows version and I'll post it there. Very cool! Thanks for posting it
Apr 10 '10 at 06:24 PM
Michael La Voie
(comments are locked)
|
|
Your guess is correct TheLameDuck - Unity is still only up to C# 2.0. That means no var declaration, no nice collection initializers, and no Linq.
(comments are locked)
|
|
We managed to replace only the gmcs.exe (without replacing any other file) And almost all 3.0 languages constructs became supported. Since it's a compile time only change it seens pretty safe. We tested this change with a project with hundreds of c# classes We used unity 2.6.1f1 and gmcs.exe 2.0.50727.143 you're right... you don't need a new mono.dll (or the related files). i've updated the instructions
Mar 07 '10 at 02:05 PM
Lance Sun
(comments are locked)
|
1 2 next page »

the unity iphone 1.6 is upgraded to mono 2.6 so they will upgrade the unity too. they might do this in next minor release.