Ex2d: A helpful plugin for Unity3D


A lightweight plugin for Unity.

Our most recent in house project was a fun children’s game called Whack Attack, and was built with Unity 3D and released for iPhones and android devices.  Unity is a great tool, but it is definitely (and obviously) more geared for game crafting in the third dimension.  Our game deals mostly with two dimensional sprites, although they are set in a pseudo 3d environment to attain some basic perspective.

In development we initially utilized the two built-in techniques Unity uses to deal with 2-dimensional assets.  For in-game objects like the moles the player has to whack, we simply map a flat plane with a single texture derived from the .png of a game sprite drawn by our designer.  An important consideration in Unity we had to learn was that the program automatically compresses all incoming assets as if they were intended for 3-dimensional textures, which unfortunately destroys any fidelity that in the more meticulous 2D sprites we were working with.  It was necessary to change the image import settings from ‘texture’ to ‘gui’ and to turn off any compression.  It’s an easy change, but regrettably one that we had to do for every individual image that was imported.  Finally, a transparent shader is added so any edges are blended in to the background.

The second way that Unity deals with two dimensional sprites is through the built in GUI editor.  Instead of in-game objects placed in a 3D coordinate system, guiTextures and guiText objects make up the on-screen persistent GUI that is found in most games.  Initially, we thought that this functionality would be enough for our purposes, but after testing a release build on multiple devices and resolutions, we found it not adequate to the task.  Specifically, unity has no way of ensuring pixel perfect ratios for GUI elements.  This wasn’t that noticeable at first, but when we changed the resolution (say, from an iPhone 4s to an iPhone 5), the effect was dramatic.  The gui elements would distort to cohere with the new aspect ratio offered by the device.

This problem sent us to the internet in search of a solution.  After trying a couple 2D asset production plugins available, I settled on Ex2d.  It’s a lightweight sprite and animation plugin created after a developer needed a similar product for his own gaming company.  It was an easy installation, and after reading a quick tutorial, I was off to creating much more manageable 2D assets.

A lightweight plugin for Unity.

A lightweight plugin for Unity.

First off, the plugin includes a ‘group import’ tool, which vastly speeds up the mundane task of individually changing the compressed import settings for all new assets.  For the problematic GUI elements, the new exSprite class has a number of helpful tools designed for exactly what we had in mind.  Firstly, a ‘pixel perfect’ option was a welcome addition.  It even took into account what scene camera we were using at the time to make sure the resolution was intact.  Now we could ensure GUI elements were exactly the way they were supposed to be in our scenes.

For in-game objects, the appeal is primarily on an easy integration with sprite-sheet based animation to reduce draw calls.  Draw calls are among the worst performance offenders on mobile devices, so it was nice to see a way to potentially reduce them in action.  The idea is to pack all the individual animating sprites together into a single texture, and then get the exact one you need at runtime programatically.  Ex2d has a nifty sprite sheet creation tool packaged with it, and I can’t wait to experiment as we add more complicated animations to this and other games.

The ease of integrating such a useful new plugin continues to show me how versatile the Unity platform is.  As our games and other internal projects increase in scope and complexity, it’s a good feeling knowing that quality tools exist in the wilds of the internet waiting to be utilized.

1 Comment

  1. In building 2d games we avoided unity due to its complexity. We usually went with cocos2d which now has a c++ version that can port to android with cocos2dx. BUT cool find!

Leave a Reply

Your email address will not be published. Required fields are marked *