Search code examples
c#.netunity-game-enginemono

Mono vs .NET in Unity


I use Unity with Visual Studio and it's brilliant. But I'm confused about how exactly .NET, Mono and Unity are related to each other. Are these statements right or wrong?

  1. .NET Framework was not designed to be cross-platform.
  2. The goal of .NET Framework is to design programs in a unified way, and they must all run in a virtual machine.
  3. Mono is an open source version of .NET Framework, designed to be cross-platform. Programs built with it can run wherever the Mono virtual machine is installed.
  4. Programs built with Mono cannot run or are not fully compatible with the .NET virtual machine.
  5. Unity only uses Mono for editing, building, and running games.
  6. Games built with Unity have the Mono framework and/or virtual machine embedded in them.
  7. I don't need to have .NET Framework installed for building or running Unity games.
  8. The C# scripts I wrote in Unity are run by a Mono virtual machine, before and after build time. All the Unity engine public code library is C++ wrapped and not actually C#, thus it is running in a C++ side engine.
  9. The Mono framework tools and library are run in-game with a Mono virtual machine.
  10. DLL built with .NET Framework are not fully compatible with Mono.

Solution

    1. .Net frameWork was not designed to be cross plateform.

    Depends on whether you wish to include say Linux in that. If you are asking if .NET was originally designed to target Linux then, no. However there is the .NET Compact Framework which allowed .NET code to run the Xbox 360 and Windows Phone.

    There is now .NET Core, a free and open source framework which is designed for cross platform, specifically Windows, Mac and Linux.

    1. The .Net frameWork goal is to design programs in a unified way, and they must all run and a virtual machine.

    Yes. The correct term is Execution Engine by the way not VM though they both are in the same class. Don't think of the EE as something akin to vmWare where CPU instructions are constantly emulated. .NET like Java and are a form of p-code however .NET assemblies are JIT'd to the current CPU so as to improve performance and run natively on the CPU. [1]

    1. Mono is an open source version of .Net frameWork, designed to be cross plateform. Programs built with it can run wherever there is a mono virtual machine.

    Yes. .NET Core has the same claims. [4]

    1. Programs built with mono frameWork can not run, or are not fully compatible with .Net virtual machine.

    The Mono Framework across it's many versions is not a 1:1 of the equivalent .NET Framework.

    e.g.

    • Mono has no support for WPF in .NET 3.0 [2]
    • Mono has no support for WWF in .NET 3.0 [2]
    • Mono has no support for CodeContracts in .NET 4.0 [2]
    1. Unity only use Mono frameWork, either in editing, building and running games.

    Incorrect. Unity also uses Unity Script for composing a game.

    However there is a big difference for runtime irrespective of your language choice. When targeting say a web browser via Unity Web Player, there is no .NET/Mono EE. The platform is the Unity Web Player. In this sense .NET/Mono is not required on the target platform. [3]

    1. Games built with Unity have embeded mono framework and /or mono virtual machine.

    Incorrect, see above

    1. I don't need to have .Net frameWork for building or running Unity games.

    Correct

    1. The C# scripts i wrote in Unity are run by a mono virtual machine, before and after build time. All the Unity engine public code library is c++ wrapped and are not actually C#, thus they are running on c++ side engine.

    Incorrect, there is no correlation between what language you choose to use to write your Unity game in and whether or not the .NET/Mono EE is present at runtime.

    1. The mono frameWork tools and library are run in game with a mono virtual machine.

    Depends.

    • On your desktop whilst running the Unity Editor? - Yes
    • Deployed at running on a smartdevice/browser? - no
    1. Dll built with .Net frameWork are not fully compatible with mono.

    Incorrect. It is Mono that may or may not be fully compatible with the equivalent .NET Framework. [2]

    See also

    1 "Is the CLR a Virtual Machine?", MSDN

    2 Compatibility, Mono

    3 How does the Unity Web Player work?, Quora

    4 .NET Core Framework - Go Cross-Platform with the .NET Framework, MSDN