The Animal Farm

January 31st, 2014

Thoughts on NGUI

NGUI is regarded as one of the best UI frameworks for Unity. It’s constantly on the front page of the Asset Store, it has high reviews, and everyone I talk to swears by it. It’s good, but it has some serious failings. Let’s chat about it:

I put this first, because it’s a really glaring black mark on NGUI. It’s just not very well documented. Most ‘how to’ guides are in video form, which is not great if you want to get at information quickly. The small bit of text there is is… poorly written and confusing. The guide on UIGrid is a crazy mismash of information that leaves you more confused than enlightened. And 85% of the documentation is woefully out of date - they use the wrong class names, legacy workflows, or have just become plain wrong. It’s almost impossible to suss out exactly what your’e doing without painstakingly combing through examples or wildly guessing until you strike gold.

NGUI actually has a lot of stuff. It’s trivially easy (once you know how) to setup a table, make it scrollable, and rig it in such a way that it works across all resolutions. Complex widgets & interesting interactions are never terribly hard. In fact, I can’t think of a single widget I’d want that I can’t hook up in NGUI with a little effort.

I can’t speak a lot here - I haven’t dived too much into the localization system. But I do know at least one good thing and one bad thing. First the good: NGUI supports dynamic fonts as opposed to being exclusively bitmap font oriented, which is practically a requirement when you’re localizing to Asian languages. And the bad: the word wrapping for Asian languages is just wrong. They use a naive algorithm based exclusively on white space separation, and that’s just not good enough for most Asian languages. It’s a shame, since this is a pretty hard problem.

Unity 4.3 Integration
Unity 4.3 introduced 2D workflows as a first class citizen of Unity. NGUI quickly integrated it, but not in a particularly robust way - it’s impossible to use a Unity Sprite as a 9-slice. Which means if you want 9-slices, you’re forced to juggle NGUIs atlasing system & Unity’s. Not impossible, but not ideal. There’s nothing stopping them from doing this. I’ve dug into the code and seen how they render Unity Sprites, and the system could be extended to support 9-slices, but it’s not entirely trivial (NGUI has a system of complicated editors where setting up the right information is a little tricky).

That’s all I can talk about right now. I’d like to speak on performance, but I don’t know yet - I haven’t created a UI significantly complex enough to tax the system, and I’m unversed in Unity performance in general. So… let’s hope that doesn’t explode for me.

As of this writing, Daikon Forge looked like a decent competitor, but I couldn’t get the trial running on my system. There are certainly a few other solutions, and some of them might be good, I encourage you to explore them and let me know.

January 30th, 2014

Thoughts on Unity

I’ve been looking heavily at Unity these days, so much so that when I participated in Ludum Dare a couple months ago, I opted to make a jam entry with the engine.

There are some good things about Unity, some great things, some obnoxious things, and some little quirks. I’d like to discuss them here in no particular order.

Oh, how I’ve missed you C#. I’ve spent the last three years of my life coding exclusively in Objective-C. I’ve come to terms with Obj-C, much of my initial vitriol toward it has dulled, but I never grew to like it. I like C# though, and I’m constantly amazed at how much more comprehensive the C# standard library is; when I was porting over a lot of useful code, more often than not I found there was no porting required because C# already had an equivalent method in its library. I don’t know yet how well garbage collection performs on mobile - that worries me a bit given my experience on other platforms, but we’ll see.

Multiplatform Support
Unity touts itself as being completely multiplatform, and that’s true and it isn’t. It can certainly build to every platform, but there are gaping holes. There’s no such thing as a per-platform asset - there are *settings* on a per-platform basis, but you can’t, for instance, use one texture on Platform A and a different texture on Platform B without either loading both textures or sacrificing usability within the editor. This gets worse on mobile, where you certainly don’t want to load iPad Retina images on an SD iPhone, but getting around that is especially hard.

The current UI system is pretty laughable for a large project. The only real options are in the Asset Store. Unity has been working on a new UI system, but I have it on good authority that they’ve been working on that UI system for forever and that I probably shouldn’t hold my breath.

This falls under one of those ‘great’ categories. Physics systems are hard; I’ve coded a few and never really got a good handle on the area. With Unity, though, it’s really just setting up some colliders and tweaking parameters. It’s not a solution to everything - good platformer or car physics is still hard - but it’s a really nice starting point.

The Unity editor is pretty good. It’s intuitive, powerful, and easy. It’s also incredibly extensible, allowing you to easily create custom editors & functionality when necessary. Conversely, MonoDevelop is not that great - the Intellisense is horrid, the autoformatting is obnoxious and hard to configure properly, and the debugging can feel wonky. Plus it doesn’t interface very well with the main editor: half the time I double click to open a file, I get the wrong file or the wrong project entirely. It’s not unusable, but I probably liked Xcode more, and that’s… unfortunate.

External Plugins
I’ve had to interface with Obj-C land for a few custom plugins, and it was really, really pleasant. Just wrote some code, and Unity pulled it into the Xcode project seamlessly. It’s not perfect though - there’s no proper way to add frameworks or change the Xcode project’s linked libraries without modifying the Xcode project manually. That’s Apple’s fault though. They just didn’t provide a way to modify Xcode project files outside of Xcode. A few clever people have reverse engineered the Xcode format for doing this, but it’s a brittle and dangerous solution.

Asset Store
The Asset Store is awesome. There’s a ton of stuff in there, and it’s mostly reasonably priced. Not a lot to say here though - it’s just full of good stuff.

That’s enough for now. It’s just a small look at the toolset, and I’ll probably have more to say in the future. There have been some hiccups, some larger than others, but you’ll have those with pretty much any system. Overall, it’s been a perfectly pleasant experience.