Use Case: I power up Unity start a new project get the default scene and hit play. Now for input I have used about 5 clicks and a few keystrokes for project name so I have typed about a word or two and the whole process has taken about a minute of two (project generation time).
Now the question is how many lines of code and how much data have I had ‘automagically written’ or generated?
I’m sure that’s very dependent on the platform. But also not really relevant, I don’t think.
I’ve heard people brag about the size of projects (“Over one million lines of code!”) and others denounce length (“No single file should be over 500 lines!”) and any time I hear it, I just wonder why it matters. If your code is readable and easy for you/your team to maintain, being short or long doesn’t really matter.
More impressive, in my opinion, is how many lines of code you don’t have to write to get that blank screen looking at you when you run an empty project. After trying and failing repeatedly to get into game development using Java, HTML5, and a handful of other languages or platforms, the stuff that I don’t have to build or worry about in Unity – the game loop, rendering, or the asset pipeline, for example – is where I’m most amazed and appreciative.
Maybe I’m not clear on what your next thought step is from this knowledge.
Are you trying to do the math on how much time Unity saves you from having to write those lines of code yourself? Or if there’s a way to optimize build sizes based on reducing the number of generated code lines in an empty build? Or compare an empty build’s code to that of another engine?
In any of those cases, I don’t think the number of lines of code is relevant, is what I was trying to say. So other than just “I’m curious”, I don’t know why it matters. If it is just a chit-chat type of pondering, my answer is “I have no clue, but I assume a lot. Or perhaps very little.”
Lines of code have very little meaning. It certainly does not indicate whether or not code will function appropriately. If I had to guess though I would imagine it has far fewer than you would expect given the sheer amount of middle-ware that is actually doing the work.
Why does it matter? Are you concerned about the minuscule time to create a new project? If I had to guess it only creates the directory structure, extracts the selected assets, and generates the library cache.
Or it simply does not make sense to anyone other than him.
There are probably ways to count it. Make a C++ project with some arbitrary number of lines of code. Build it. Check the file size. Keep repeating this until you have a nice graph showing lines of code versus file size.
Then do the same thing with an empty unity build.
The answer will be wrong by a long shot. But it will get you into the ball park.
I’d say there is a massive amount of code auto-generated from the libraries alone based on the fact that an executable of a blank screen on Windows is something like 8 MB IIRC. In fairness though it is just the way it is these days in general not just Unity. And it also means when you write your own code the size should increase very little because all of the API has already been stuck in the exe. It does make me wonder what is taking up 8 MB or so of code though. That is a huge amount compiled. For project source code files I can definitely see it. I’d guess it is just things like physics (remember there are two… one for 2D and one for 3D) and perhaps other 3rd party libs.
This alert system drives me like a moth to a flame …
Plus multi-platform engines are millions of lines of code generally… If you wanted to do your own they wouldn’t nearly be anywhere as big, generally because you only develop for the platforms you need. If you can build your own, than abstraction becomes less relevant and you might not even require a UI outside of the GL renderer.