My thoughts on Unity

Long time no see, right? Just for fun, I wanted to write up some (initial) thoughts on the topic of Unity, the game engine. Not sure if I've mentioned it before, but I've been keeping an eye on Unity for years (since 3.x days I think), on the prospect that I might actually use it someday for my own games.

After spending way too long on making the general engine code for Jewels 2 (remember the engine consisted of 75% of all my code in J2, quite a bit of which I ended up not needing at all!) it occurred to me that maybe it's not the best use of my time if I actually want to make games. I have two kids, a day job and generally a lot less time to tinker with gamedev than I used to, so perhaps it should be spent not making engines, but games. And I don't even want to count how many times I've started building a game (engine first, of course) and actually ended up with an incomplete engine and no game!

With that in mind I decided finally to use Unity. Early this year I got back to my old day job of making learning games for children and conveniently enough we use Unity there too, so it was a great chance to actually use the thing. Before I had only tinkered with it, made a couple of very small prototypes.

Now that we've established why I wanted to use Unity, and I've actually used it for some time, I wanted to list (not necessarily in any particular order) some things I like and don't like about it. Nothing is perfect, after all. This is from an "old school" do-your-own-engines-in-C++ -perspective, so subjective stuff all around. Also goes without saying that I'm no Unity expert; I'm still learning to get into the proper Unity-mindset and finding an Unity-ish way of doing things, which often is vastly different from what I'd normally do as a coder. (Some of you may be wondering why Unity, instead of, say, Unreal Engine? Well I'll get to that in a bit.)

What I like about Unity

  • The Unity Editor: As a programmer I'm used to doing most of things through code, but after getting to grips with the editor centric workflow it is really good. It's very handy to place stuff in editor and especially to inspect things during gameplay, at runtime. The editor is also very extensible, powerful stuff.
  • Asset pipeline: It's great to have the ability to just drop a .blend or .psd in the assets folder and have it ready for in-engine use, (usually) without much trouble. You can also extend it with asset pre/postprocessors, very useful.
  • Prefabs: I think they're neat way to encapsulate and reuse things. They do have a fatal flaw… (see the other list below)
  • Component based: Component based programming is neat! I never got around trying that in my own stuff even though I always wanted to try.
  • C# scripting: After over 15 years of battling with C++; header files, fugly templates, const references, copy constructors and all that shit, C# feels like breath of fresh air. This is the main reason I didn't consider Unreal Engine that much; C++ feels cumbersome and counter-productive after spending some time with C#. Not to mention compile times, C# is much faster to compile. So in short: if I have the option of not using C++, I'll gladly take it.
  • Co-routines: Useful as hell; can't count how many times in the past I've had to add vars for various counters, polling when certain stuff should happen. In J2 I made an event scheduler that allowed rigging timed events, repeating or one-shot to happen, but co-routines make all that so simple I don't know what could possibly be better than them!
  • Cross platform: It isn't quite the "one click and your game is ported", but halfway in the general direction at least. iOS remains a painful platform to develop on even with Unity, since Apple doesn't allow JIT (Just In Time) compilation and code has to be compiled AOT (Ahead Of Time).. Do anything fancy and you'll find that it doesn't work on iOS without having to pull tricks like making dummy code reference all the types that would otherwise get missed during the AOT compilation.. But I digress, it's still whole lot better than spending all the time in Xcode.
  • Prototyping: Unity is excellent prototyping tool! I usually don't do much prototyping (does it show? :D), but with Unity I have and it's been helpful testing stuff without "officially" starting a new game project.
  • Powerful animation: Mecanim is quite powerful if a bit convoluted, and can animate almost anything. I still do lots of tweens from code, but I'm using animation for more and more things.
  • And finally… (I've saved the best thing last) — not having to write everything myself! ;)

What I don't like about Unity

  • Outdated Mono: Mentioning this is something of a cliché, but yeah better GC and updated .NET would come in handy. Luckily once Unitys il2cpp-project matures these problems should finally go away.
  • No nested prefabs: Suffice to say, prefabs would be super awesome if they could be nested and then updated properly. Maybe one day…
  • Magic methods: MonoBehaviour magic methods (such as Update(), OnEnable(), OnDisable(), etc.) feel like they should be inherited or implemented with various interfaces. What I'd like is a new ScriptBehaviour that has the basic methods to override, and bunch of optional interfaces for special stuff (like physics handlers). Or maybe user code could subscribe to events like this.OnUpdate += MyUpdate.
  • iOS development == shit: Sorry, had to add this here again even though I mentioned it in the above list. It's pain in the ass due to the AOT problems, hopefully il2cpp helps with these!
  • Shuriken scripting: Shuriken is a nice particle engine, but I'd like a complete API to all its features from code.
  • 2D still lacking: The (relatively new) 2D tools are great, especially the fill-rate saving tight mesh generation for sprite atlases is helpful for mobile devices. However, there are still some omissions that I'd like to see: automated HD/SD support for atlases, dithering for 16-bit sprites (quite low hanging fruit IMHO and would improve visual quality a lot, especially for Android where 16-bit is the default "compression"), built-in support for premultiplied alpha (must for doing additive and alpha blending in same pass), a way to control the tight mesh quality, etc.
  • Pricing: I think the Unity Pro-price is ok, IF it would include all the mobile platforms. As a mobile dev, having to buy 3X the Pro-price it's a bit too much for my liking. And Pro-subscription does not make much sense: you don't get to keep the license after you've reached the normal Pro-license value. If that was not the case I'd have bought the subscription months ago. Of course even though I complain, I still need those Android Pro and iOS Pro licenses eventually, so I'll just have to bite the bullet and buy them.
  • No source access: This is usually not a problem, but when things don't work as expected, for me the best way to debug is to look what the library/engine code does and actually expects. It takes a lot of the guesswork out of debugging, but I realize having Unity open source would probably not be possible with the 3rd party stuff they're using. Luckily some of the sub systems will be open sourced, such as the new uGUI. Speaking of which..
  • The mythical uGUI: Now the long-awaited uGUI is finally here, albeit in beta form. It's mostly great — and thinking back on how much time I spent building the GUI components, menu layout and transition stuff for Jewels 2 — I'm just glad there is a proper GUI in Unity! Still, have to admit I was a bit disappointed, there were quite a lot of bugs and strange omissions (no drag threshold!?) considering how long it was in the making.. Nevertheless GUI is a complex beast + it's much better than having no GUI at all, and I'm sure it will only get better when the bugs are ironed out and the system is open sourced.
  • Terrain: Old, clunky and very slow to load on mobiles. Don't use it myself but at work we've been battling with it more than enough.
  • Easy to freeze the editor: Granted, this is an user error, but if you accidentally make an infinite loop in code, you're pretty much screwed if you had unsaved things in the editor. :P Before I would just kill the game, fix the code and that's it. Now there's potential to lose some of your Editor-made edits, if you forgot to save.

So there. My initial impressions of Unity. I'm sure I forgot some points I wanted to mention, but I will update this later if anything worth adding springs to mind. No doubt using Unity more will reveal new pain points, but I still believe that it is better to use an engine (be it Unity or Unreal or whatever) these days, IF your intention is to make games and not to tinker with lower level mechanisms. And for me, personally, seems that Unity is a great choice. :)

UPDATE on October 6th: added notes about co-routines, terrain and iOS development being shit.