What is the difference between C# script and C# .NET?

Hi, I’m new here. I just downloaded and played with Unity 2.6 I know that Unity support 3 script languages. I intend to use C# but what I don’t understand is the “script” keyword. What’s the difference between C# script in Unity and C# .NET in Visual Studio? Are there any limitation of C# script in Unity compare with normal C# .NET? One of the limitation I’ve read in doc is that Unity uses mono and some C# features in .NET are not supported in mono which means that some codes can be compiled in Visual Studio but it may not compile in Unity. Am I correct or not? :?:

Sorry if this question has been asked before. :sweat_smile:

Mono is an alternative implementation of the .NET runtime. You can use mono to run C# applications created for .NET (with certain caveats).

What Unity does, is include Mono in every application it produces, that executes your C# source (much like your C# source would be executed as a standalone application).

AFAIK you can’t specify any custom class libraries to include in the app and there might be limitations in what classes of the standard .NET APIs you can access (might be wrong about this, though).

The reason why Unity C# has limitations when compared to the regular .NET C#, is that Unity uses an outdated version of Mono (afaik. Though, they’ll likely bring it more up to date in future releases). The Mono version that Unity uses does not support the latest C# specification. The iPhone version of unity produces builds that support an even older .NET version (1.1) and that’s the reason why Boo can’t be used on iPhone (I think).

Just a few points to add/clarify from your explanation, Kirsis:

First, you CAN use external class libraries with Unity, but this is a Pro-only feature. Unity Pro supports external .NET libraries, native windows .DLLs and Mac frameworks.

The only limitations on the .NET APIs you can use in Unity is the Mono version (well, in Unity iPhone there are some additional limitations). The version of Mono used with regular Unity implements everything up to .NET version 2.0. As long as the APIs you want aren’t .NET 3.0 or 3.5 only, you can access them fine.

Also, while you’re spot on with the Mono version info, I think the lack of Boo support in iPhone is a separate issue entirely, mostly to do with the lack of support for dynamic typing in the AOT compiler that allows Mono to be used at all on the iPhone.

Thank you for the clarification. But I’m still curious about using external class libraries. I’ve searched about this topic and I got the idea that I can only use C++ libraries in pro version but I can use C# libraries in indy.

http://forum.unity3d.com/viewtopic.php?p=214324&highlight=plugins+indy#214324

Can someone confirm about this info? I also found this useful thread.

http://forum.unity3d.com/viewtopic.php?p=236527&highlight=plugins#236527

I guess that this is the only way to use C++ libraries in indy version.

Thanks for the clarification on using external class libraries, dawvee.

My reasoning for assuming the .NET version is to blame, is that http://boo.codehaus.org/Duck+Typing states:
“Boo is a statically typed language, like Java or C# […] Your compiled assembly will still be CLS compliant (usable from other languages) if you use duck types. “Duck” is only a virtual type during the compile process.”

Based on this, I figured that the iPhone runtime lacks some features that are required to fake dynamic typing. Dynamic typing isn’t a core feature of CLR, so if Boo can fake it, using core features, then compiling ahead-of-time should work, as far as the required core features are supported.

I admit, though, that my knowledge of how these languages work is very casual :slight_smile: Either way, it doesn’t matter. The .NET Reflector can be used to convert Boo to C#. I assume it could somehow be used to convert (or assist in converting) a Boo script codebase to C#, in order to use it on the iPhone :slight_smile:

Boo likely depends on .NET 2.0 functionality which you just don’t have on Unity iPhone, its pure .NET 1.1

Sorry to resurrect an old topic,

but there really needs to be a manual page about this. Ive been mostly looking through forum threads looking for how to attach a C# .net 2.0 dll to unity, if it can be used by the web player and how exactly to attach…