Wednesday, September 29, 2010

iPhone Development with Unity 3

Today, the „new“ mobile platforms - iOS, Android, WebOS and soon Windows Phone 7 - are among the hottest platforms for software developers.
But unlike past mobile platforms, thanks to the powerfull graphics hardware in these new generation of smartphones, these mobile platforms are especially interesting to us, the game and media developers out there, too because they allow us to unleash realtime graphics in a quality previously restricted to the closed handheld platforms from Nintendo and Sony.
These new, powerful mobile platforms are only beaten by the web, especially the social monster platforms like Facebook and MySpace or platforms like BigPoint which are gaming focused social platforms that are no short from stunning.

So its no wonder that more and more developers try to push into these fields, some with more and some with less experience.
That brings me to the core topic of todays blog which is about how to get into this field, create stunning visuals if you aren’t among the gifted ones with a deep dark art ninja background in 3d math, shaders and engine programming, because today, all is about developing iPhone games using the Unity 3 engine with its iPhone Platform addon, what it enables us to do but also what has changed compared to the previous version, Unity iPhone 1.7!

Unity 3 builds upon the base that Unity 2.5+ created for the desktop side last year with a much stronger and more powerfull editor framework and some serious enhancement to productivity. Unity 3 took that and added various new powerfull features to further raise the bar on this end like the possibility to make objects snap to any polygon surface by just pressing a button while dragging it, by unifying the various editor versions that the different platforms had in the past and make it all happen from a single editor through the possibility to define the target platform of a project.
Unity 3 also kept those things alive that already in the past made Unity outshine its competition: A very fast, productive workflow which has a significant impact on your development! Be it the time required to create an early prototype of your game (which is commonly a matter of days at maximum), which you can test over and over on the fly without waiting for the lengthy iphone deploys every time thanks to the Unity Remote application. The new graphics emulation options help you getting a pretty good feel on how it will look in the end on the device.
Also the art pipeline is still as simple, powerfull and straight forward as it always has been. Drop in, wait for it to be processed, reconfigure the import settings and use it. Simple as that.

What is new to this streamlined and performant environment is that Unity 3 adds MonoDevelop to the equation, likely the best C# editor available on OSX. But UT went further than just supporting it, they made it capable of being used for UnityScript as well but much more importantly: Unity 3 adds debugging, a long requested and awaited things, handled through monodevelop and its rather major environment for this purpose!

These things together make Unity 3 one of the most performant, powerfull yet still easy to use platforms for iPhone development available to date and that without sacrificing performance on the application as the engine is highly optimized and feature packed.

For users of Unity iPhone 1.7, these features definitely will add some serious extra value because although you thought you could do fast before, you will rethink your definition of fast once you used Unity 3 :)

But thats by far not all that Unity 3 gives us on the iPhone platform, many other new things found their way in.

One of the most important changes over Unity iPhone 1.7 is related to the iOS platform and the power it offers if you can unleash it meaningfully.
With iPhone 1.7, unleashing this basically required you to own the Pro version of the license, simply because Plugins (native C code binding to talk directly to UIKit etc) were a pro only thing.
But with Unity 3, Unity Technologies has reconsidered this feature delta and I’m pretty happy to let all those of you who don’t keep a close eye on the things know that with Unity iPhone 3, both licenses give you the power to unleash the iOS in your application through native function calls!
Yes you read right, with Unity iPhone 3 you can use plugins in your iphone application, independent on if you own the Unity iPhone or Unity iPhone Pro license, giving you access to various previously „unusable“ third party systems and giving your programmers the tools they were waiting for to give your game its very unique iOS treatment!

Unity iPhone 3 also introduces more features on the architecture end.
Where you previously always targeted ARMV6 and OpenGL ES 1.1 only, unity 3 allows you to make your application target ARMV7 + OpenGL ES 2.0, which gives you access to the new iDevices (3GS and newer, including iPad) programmable graphics pipeline, which grants you access to those advanced graphics possibilities that enabled the big companies out there to push the visual quality of their games to where are. Epics „Citadel Tech Demo“ among Carmacks own tech demos show what you can achieve through using this programmable pipeline combined with the required artistic talent, but also realtime toon shading would be an option as well as naturally rather trivial things like pixel lights :)

This visual quality is further enhanced by the new Lightmapping System Unity 3 has integrated which is using the Beast technology, a widely acknowledged standard for lightmapping in game development on Desktop and Next Gen consoles, hitting the iPhone for the first time through Unity 3 basically.

To help you keep a good performance with all this new blinky from OGL ES 2.0 and Beast, Unity 3 Pro (and iPhone Pro) got a new powerfull backup system, Umbra, a widely known and used top notch occlusion culling system that ensures that your game only sends objects to the system for rendering that are also visible to the camera at the time instead of flooding it bruteforce style. The PVS data to do this are all generated offline in the editor, they won’t kill your performance at runtime through realtime calculations of it!

For fellow developers coming from Unity iPhone 1.7 as I did I would also like to add a few words of warning on things you might be used to and „think to know“: As you might have read, Unity 3 iPhone no longer batches skinned meshes, the batching works differently and alike.
Unlike iPhone 1.7 though the performance consequences of batching and not batching on Unity 3 are totally different.
So don’t fear seeing higher numbers of draw calls as it does not mean that it will perform worse. Actually in beta prior the reactivation of the batching, the Unity 3 iPhone engine outperformed 1.7 with 3 times the number of drawcalls from Unity iPhone 1.7

What you should work with to base your decisions on if something is performant or not is the in-application profiler on the device, that will give you a solid idea what is really the bottleneck. Don’t do it basing on drawcalls unless they really go totally out of scale

This is just the tip of the iceberg basically, there is more to come from me on Unity 3, in relation to web development, iphone development and likely as well in relation to android development as I recently got a HTC Desire to get in touch a bit more with the „dark side of the mobile platforms“

1 comment:

Arne said...

great writeup!