This is a short presentation Jon gave for the first Ottawa Unity User Group meetup. We share some of the tips and tricks we've discovered at Karman while working with Unity over the past few years.
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ottawa unity user_group_feb13_2015
1. Ottawa Unity User
Group
Jon Keon – Karman Interactive
http://karmaninteractive.com
@jonkeon @KarmanLtd
Feb 13, 2015
2. Format
• Share Tips, Tricks, Experiences with Unity over
the last 3 years.
• = Good things
• = Bad things
• These are not laws, many ways to do things,
this is what has worked for us. Challenge it,
question it, we’re happy to discuss.
5. About Us
- Based in Ottawa and Toronto
- Small company (2 full time + small team of highly
trusted contractors)
- Mobile and Web, games and experiences
- Love to play with experimental and obscure
technologies
- Experiment driven, Client supported
- Experiments keep us ahead of the curve
- Client work keeps us sharp and pays the bills
10. Library Switching
– Big project with tons of textures?
iOS/Android importer takes FOREVER.
Don’t have the Asset Server license
– Check out this one simple trick
12. Library Switching
– Close Unity
– Rename Library folder
– Open Unity again to create a new Library folder
for the new Platform (happens once) or rename
previous Library folders back to just Library.
– Asset imported only imports the Deltas.
Much faster than regular switch platforms
13. Custom Tools - Nudge
– Designer gives you a PSD to match.
– You need to pixel perfect match it.
Dragging is inaccurate, manually entering x and y
coordinates is tedious.
15. Custom Tools - Nudge
– Invest in writing a custom editor tool.
– For us, H, U, J, K are keyboard shortcuts for
nudging any Transform or Transforms by a
configurable amount of units.
– Y is a keyboard shortcut to toggle whether a
GameObject or GameObjects are visible.
Matching comps is now a 5 second process.
16. Asset Management
– Difference between Author Time and Run Time
Author Time Run Time
Need to visually layout assets
in a Prefab or Scene
Only want the assets needed
for the specific platform and
specific size.
Need to switch between 1X,
2X and 4X assets to ensure
consistency
Build size is limited! (50mb
Google Play, 100mb iOS)
Need to update
assets/prefabs/scenes
frequently
Need all assets locally
17. Asset Management
– Prefabs
• Create a different prefab for each permutation?
• iOS 1X, Android 2X, etc.
• Solves pretty much all the issues but…
Makes your life hell. Change a button in one of them,
now you need to make the exact same change in all the
rest.
18. Asset Management
– Prefabs
• Have just one prefab and dynamically swap the assets?
• Getting closer, but…
All of those assets are now referenced by the prefab so they
get included in the build.
You’re going to have two sets of assets in most of your builds
with one set you never use.
20. Asset Management
– Karman Asset Pipeline (1/3)
• Build Prefabs with assets normally. (Author Prefabs)
• Anytime you hit play, save the scene or save the
project, our script runs.
• Detects all Author Prefabs with a different hash (to
detect changes).
• Duplicates all Author Prefabs and stores them in a
different folder. (Runtime Prefabs) Removes all
references to the assets on those prefabs and instead
writes a metadata script to the GameObject instead.
21. Asset Management
– Karman Asset Pipeline (2/3)
• Assets that changed are built to Asset Bundles for each
platform and each size automatically. (iOS 1X, 2X, 4X,
Android 1X, 2X, 4X etc)
• New Runtime Prefabs are included in the build. Old
Author Prefabs are not included, so no assets are
included.
• Asset Bundles can be specified to be External or
Internal so that you can fill up as much of the
50MB(Android) or 100MB(iOS) limit as you want and let
the rest be downloaded from a Server.
22. Asset Management
– Karman Asset Pipeline (3/3)
• At Runtime, Asset Manager checks platform and
screens-size.
• Downloads required Asset Bundles if we don’t have
them already.
• Whenever a Runtime Prefab is Instantiated, metadata
script pulls the correct asset from the bundle and sets
it. Runtime Prefab now looks exactly the same as the
Author Prefab but with the correct size of Assets.
24. Asset Management
– Karman Asset Pipeline Post Mortem
• Large initial investment to build.
• Return in robustness and workflow worth it.
– Benefits
Never forget, automatically happens during a Save or
when pressing Play in the editor.
Build in the editor with the actual assets. (Like you’d
expect to)
Have full control over all permutations of assets and
whether they are internal or external.
25. WWW Class
The WWW class has limitations. Basically allows
for sending simple GET or POST requests.
Consider writing a wrapper to handle retries,
timeouts, cache-busting etc.
– Headers
Look to List of HTTP header fields (Wikipedia) for what
headers can be sent and received.
Access by passing request headers to WWW
constructor and check WWW.responseHeaders when
it returns.
26. WWW Class
– Example:
• Grabs the Status Code being returned. Far more useful
for debugging than looking just at the WWW.error
property.
27. Launch From Any Scene
– You have a Main Scene that starts your game. You
press play and the game loads normally and you play.
– You’re now working in the Level 6 scene. You make
some changes and press play and everything errors
because it can’t find the player etc.
– That’s because the Player gets set in the Main scene
and you just skipped all that.
You have to save your Level 6 scene, switch to Main
scene, play and the switch back.
28. Launch From Any Scene
– Create a script that lives in every scene. When it
starts, it destroys everything else in the scene and
loads the Main Scene.
29. Launch From Any Scene
– But the scene I launched from threw a bunch of
errors to the console before we launched the
Main Scene!
30. Launch From Any Scene
– Now you can work in any scene and press play to
go to your main scene.
– You guarantee consistency in the launch flow so
there are less bugs.
– When you’re done testing, you go right back to
the scene you were working in.
Time saved.
32. Asset Store Plugins
– 2D Toolkit
• http://2dtoolkit.com/
Sprite Atlas creation is easy and has great features like:
– Custom Anchor points per sprite
– Ability to dice your sprite into smaller images so they take up
less space
– Remove duplicates (works really well with dicing)
Handles 9-sliced sprites nicely
Operates in 3D space so easy to merge 2D and 3D
content.
33. Asset Store Plugins
– Text Mesh Pro
• http://digitalnativestudios.com/
Bitmap Fonts work well for one size and can be large
textures depending on how many characters.
Text Mesh Pro uses Signed Distance Fields to render the text
crisply at any size. Textures are often smaller too.
Also has many other features for auto-sizing text, formatting
etc. If you build anything multi-lingual this plugin is a
necessity.
34. Asset Store Plugins
– DOTween
• http://dotween.demigiant.com/
Successor to HOTween.
Handles making things move… nicely.
Even in beta, it’s the best tween engine we’ve seen for
features, performance and API.
35. Conclusions
– Spend the money to explore Asset Store plugins.
• Odds are high that the cost to purchase is far lower
than the time it would take you to create it.
• It will also have been bug tested and used by many
others in live projects.
– If an Asset Store Plugin doesn’t exist, invest the
time to create your own tools.
• Pick your biggest pain point and solve that first.
• Test on a live project to find the pitfalls and actual use-
cases. Give yourself time.
36. • Concerns and Comments are also acceptable
and encouraged.
Questions?
THANKS!
Editor's Notes
We may replace with Unity’s new UI system. Still evaluating at this point.