6. A DEEP DIVE INTO UNITY UI - THE GIST OF IT
WHAT WILL WE COVER?
▸Quick overview of the other UI frameworks out there.
▸Demo of the UnityUI workflow.
▸Must-Have Add-ons/Assets for UI Development
▸Architecture; keeping things modular and maintainable
▸(Stretch) Anchoring: Strategies for dealing with multiple
resolutions and aspect ratios across platforms.
8. A DEEP DIVE INTO UNITY UI - PICK YOUR POISON
NGUI
▸ “Industry Standard” in Unity for a
long time.
▸ WYSIWYG, separate from Unity’s
2D pipeline.
▸ Hope you like Atlases. Features
custom Atlas packers for fonts and
sprites.
▸ Bitmap fonts for text recommended.
Lackluster dynamic font support.
9. A DEEP DIVE INTO UNITY UI - PICK YOUR POISON
UNITY UI (FORMERLY
CALLED UGUI)
▸ The official Unity UI Solution.
▸ Adapted from and well-integrated
with Unity's 2D tools. Also
WYSIWYG.
▸ Dynamic Batching (no Atlases to
manage).
▸ Dynamic Fonts only.
10. A DEEP DIVE INTO UNITY UI - PICK YOUR POISON
SCALEFORM
▸ Probably the most commonly used
UI framework in games (outside
Unity).
▸ A more expensive but fully featured,
flash-based UI framework. Probably
still has a UnitySDK.
▸ Authored outside of Unity.
▸ Action script.
▸ Vector graphics.
11. A DEEP DIVE INTO UNITY UI - PICK YOUR POISON
COHERENT UI
▸ HTML/CSS/Javascript, authored
outside Unity.
▸ Costly but jam-packed with features.
13. A DEEP DIVE INTO UNITY UI - PICK YOUR POISON
SO, WHY USE UNITY UI OVER OTHER
FRAMEWORKS?
▸Free. Open Source.
▸Official solution. Not just a one-man-show, not just an after-
thought integration by a 3rd party.
▸Better editor integration. Editing and iterating inside Unity is
a simpler, faster, and often more approachable workflow
than editing externally.
▸Better compatibility with Editor Extensions / Asset Store Add-
ons.
22. A DEEP DIVE INTO UNITY UI - ARCHITECTURE AND
MAINTAINABILITY
SYMPTOMS OF BAD
ARCHITECTURE
▸ Fragility/Brittleness: hard to change
things; doing so breaks other things.
▸ WETness: Many similar things are
implemented different ways.
▸ Lack of tests. Hard to write tests, or
tests are fragile.
▸ Code smell. Prefab Smell. Scene
Smell. Your project smells.
25. A DEEP DIVE INTO UNITY UI - ARCHITECTURE AND
MAINTAINABILITY
UI PREFAB
MANAGEMENT IS
KEY▸ UI “elements” work best as prefabs.
But, whole UI views should be
prefabs as well. Hard to have both
without getting fancy
▸ Prefab nesting allows you to properly
keep track of “prefabs inside other
prefabs”
▸ Prefab inheritance to better
encapsulate prefabs and control how
changes propagate to related
elements
26. A DEEP DIVE INTO UNITY UI - ARCHITECTURE AND
MAINTAINABILITY
CONSIDER
STANDARDS AND
PATTERNS▸ MVC provides a scalable way to
separate data and logic (model),
input handling (controller), and the
presentation of the UI elements
(view).
▸ IoC (Inversion of Control) is a better
way to manage dependencies for
your UI. Check out StrangeIoC.
27. A DEEP DIVE INTO UNITY UI - THAT’S ALL FOLKS
THANKS!
▸ Feel free to e-mail me:
charlie.helman@gmail.com
▸ Or follow me on Twitter.
@charliehelman
Notas do Editor
First,
First,
First off, it’s free. Free with a capital F. CoherentUI costs a couple thousand, scale-form isn’t cheap, nGUI is $90 per seat.
The source is up on bitbucket, meaning there’s opportunity to customize it if you ever run into a situation where something doesn’t meet your needs. Open source contributions are pretty common, and community tweaks that don’t make it into the official source are out there and can be a lifesaver.
Because it’s the official solution, Unity has an entire team of engineers and designers working on it. They have a vested interest in developing new features, keeping the bugs at bay, and they have the man-power to do that. nGUI is made by one guy. Coherent and Scale-form are smaller teams where Unity integration is seemingly lower on the priority list because it’s not their primary cash-cow.
Better integrated in the editor, and building your UI in-engine is typically quicker and easier than doing it in an external app.
Plus, because your UI is just a bunch of game objects with components stored in Unity scenes using Assets stored in your Unity Project, there are plenty of editor extensions out there that work well to enhance it.
Spend 10 mins building a main menu.
And one of those editor extensions is our first essential add-on, Text Mesh Pro.
The text and font management tools in nGUI and UnityUI are cool and all, but ultimately they leave a bit to be desired.
While they support most of the basic sorts of things you’d want a text label to support, it won’t be long before you find a case that they don’t really support. Plus, they’re flawed in the way they render text.
In nGUI’s bitmap fonts, you have to bake your fonts to be as large as possible, but even then, get up close to the text, or present it at any type of angle, pixelation will rear its ugly head. This is especially prominent with text labels that are rendered in 3D world space instead of screen space, where players often find ways to get up close and personal with the text.
It also kicks the crap out of nGUI’s and UnityUI’s text styling features.
It also kicks the crap out of nGUI’s and UnityUI’s text styling features.
Brittle/Fragile: Fights break out on your team when requirements change because systems are inflexible in their implementation that making a change often breaks things.
WETness: Stands for write-everything-twice, or we-enjoy-typing, or waste-everyone’s-time. You might have a WET project if DejaVu is a common sensation when browsing through your project or codebase. The solution to a problem is rewritten differently every time it comes up, or many similar things are implemented different ways, or straight up copy-pasta’d in multiple places in your code. You might be surprised how common that is, especially when you’re under harsh timelines.
Tests: Speaking of things that suffer due to harsh timelines — tests! For a long time, I used to think “testing stuff in Unity is too hard.” Really, our bad architecture was what made it hard. It’s hard to test UIs and the logic behind them when they’re so tightly coupled to other systems, for example.
Finally, code smell. This is a term that also usually describes code, but I think, after all the stuff I’ve seen, can fairly be extended to the rest of a Unity project as well.
Spend 10 mins explaining using prefabs, the limitations of just using prefabs, and then talk about prefab inheritance and nested prefabs and how they can be used in UI development.