Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

What's the difference between playing in editor and building

Discussion in 'Editor & General Support' started by SalahChafai160, Jun 30, 2020.

  1. SalahChafai160

    SalahChafai160

    Joined:
    Dec 29, 2018
    Posts:
    8
    this might be the wrong place to ask this but i didn't find a better place, my question is what's the difference between playing in editor and building a .exe file, cuz playing in editor takes only few seconds while building can take a very long time..i'm interested to know what's the background process that's going on while in editor exactly and how it's done (out of curiosity)
     
  2. elliotfriesen

    elliotfriesen

    Joined:
    Mar 17, 2020
    Posts:
    71
    The build in general is just how the game will look when you upload it to a site, the editor will usually run less productively because it has lots of background action happening in unity, if you ever want to see what your game looks like when you upload it, then the build is the way to go
     
  3. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    In over-simplified terms, the editor compiles the game as quickly as possible to be able to test it without much waiting, whereas a build compiles the game to be as optimized as possible, which is a slower process.
     
    PraetorBlue likes this.
  4. SalahChafai160

    SalahChafai160

    Joined:
    Dec 29, 2018
    Posts:
    8
    i know all of these things, my question is how the editor does that, cuz by default you have to build the game to run it however is some game engines (unity, unreal, godot) there's this magic trick of running the game without building it, so i want to know how they do that, like how do they compile the game so quickly
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    Compiling your scripts and loading the scene is pretty much all Unity has to do to play the game in the editor, since the editor itself is already there and contains the entirety of the game loop and all of the builtin Unity stuff. Unity also uses the Mono scripting runtime in the editor, which is not as optimized as IL2CPP, but Unity doesn't have to rebuild the whole runtime from scratch when you use it.

    On the other hand, when you build the game, Unity has to create an executable that contains not just your scripts, but the entirety of the Unity game engine for whichever platform you're targeting (including all of Unity's C# scripts as well as the CPP game engine). Again, depending on the target platform, Unity has to do a bunch of extra stuff. If it's a platform where IL2CPP is used, Unity takes all of your code, compiles it to IL, then compiles that IL to CPP source code, then compiles that CPP source code to a runnable binary. It's a lot of work!

    Also according to this page your PC may be doing extra work like analyzing your build for malware which adds a ton of time to the process: https://docs.unity3d.com/Manual/IL2CPP-OptimizingBuildTimes.html