Search Unity

How is it that Unity can compile a game for multiple OS's from one OS?

Discussion in 'Getting Started' started by 0rr3n1, Jun 1, 2015.

  1. 0rr3n1

    0rr3n1

    Joined:
    Apr 16, 2013
    Posts:
    1
    I have been thinking about this for a while. How is the unity game compiler able to compile a game for windows, mac, and linux if I'm working from a windows machine for example? For Unreal Engine for example, you need to be on the native OS in order to compile the game for it. Any insight?
     
  2. CodeMonke234

    CodeMonke234

    Joined:
    Oct 13, 2010
    Posts:
    181
    The concept is called cross-compilation.
    It is a core component for any toolchains targeting a specific platform. If you think about it, the first program for any new machine must be able to be built from a different machine that already exists .
    The idea is very cool.
    Unreal does have forms of it as well - for example if it is Blueprints-only you can build iOS on Windows.
    There are some constraints in Unity... for example to build for iOS you must be on mac.
    For the most part, the core engine runtime does not need to be rebuilt each time - only the c#.
    A runtime is built for each supported platform and this executes the project specific behavior code.
    http://blogs.unity3d.com/2014/05/20/the-future-of-scripting-in-unity/
     
  3. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,412
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,203
    No, you can do that on Windows. However the resulting XCode project needs to be compiled with XCode, which only runs on OS X.

    --Eric
     
    calmcarrots likes this.
  5. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,412
    Don't want to get overly picky but, "Generating a project" IMO does not equate to 'Build' to build you must use a mac hence the "for example to build for iOS you must be on mac" is correct IMO.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,203
    The point is that Unity can build iOS projects on Windows; that wasn't always the case.

    --Eric
     
  7. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,412
    We're discussing terminology here. IMO the general use of the term 'build' is to generate the usable binary, not generating a project that can then be built.

    But your point is taken :)
     
  8. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,791
    (You can also build on Windows using the outputted project with tools like ios build environment ;))
     
  9. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,218
    Hard to say. Since Unreal has features Unity doesn't and vise versa.
     
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,608
    Yeah, probably should have included a smiley face
     
  11. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,218
    I don't want to start UE vs. Unity war. :p
     
  12. Sslaxx

    Sslaxx

    Joined:
    Jul 11, 2012
    Posts:
    47
  13. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    "How is it that Unity can compile a game for multiple OS's from one OS?"

    By magic
     
    Ryiah, Kiwasi and CodeMonke234 like this.
  14. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    12,327
    Compilation doesn't care about the environment it's running in. As long as it knows enough about the target environment to generate correct machine code output then it's fine.
     
  15. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,608
    There is a lot to this. Every script except the one I have open on my IDE works by magic. That includes all of the engine stuff underneath as well. Coding by magic is pretty great.
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,930
    Partly because on most platforms, we actually only compile your C# scripts - the actual engine that's written in C++ for every platform comes with editor installation precompiled. So we don't really need to compile anything platform specific.

    There are exceptions to this, of course: on iOS and Windows Store platforms, we generate XCode/Visual studio projects which then need to be compiled to produce the final application package.
     
    Sslaxx, Ryiah, larku and 1 other person like this.
unityunity