Docstoc

Using the Unity Editor APIs

Document Sample
Using the Unity Editor APIs Powered By Docstoc
					Using the Unity Editor APIs
Jonathan Czeck, co-founder Graveck Interactive LLC




                                                     1
Why should I care?
 •   You usually don't NEED to, right?

 •   3 Seconds Per Task == 8 man-hours over a project...
     76.2% of the time.

 •   "Production" time

 •   Unlock ideas

 •   Save errors

 •   Laugh maniacally at the monitor

 •   Present about Editor APIs at Unite ‘09!

                                                           2
Overview
•       Quick intro to the API

•       Some of our use cases:
    •    The Facilitator
    •    RC Laser Warrior
    •    Sooga Mountain Super Race
    •    Benard's Honey Pursuit

•       Future plans and audience placation




                                              3
Intro to the API
 •       Documentation!
     •   From Unity, choose Help->Script Reference
     •   Choose "Editor Classes" from the menu on the left.
     •   Try not to drool.

 •       Unity 1.x: 8 editor classes and enumerations

 •       Unity 2.1: 46 classes and enumerations. Almost 6x!

 •       Over 9000x the power!

 •       Best solution moves! D'oh



                                                              4
Four Main Types
•   Simple menu items

•   ScriptableWizards

•   AssetPostprocessors

•   EditorWindows




                          5
My Favorite Editor Script



 •   MenuItem class documentation for more shortcut info

 •   Saved eight hundred billion hours to date.




                                                           6
ScriptableWizards
 •       More power

 •       Can take explicit user input

 •       Any types you'd see in the Inspector

 •       Anatomy
     •   SampleScriptableWizard.js




                                                7
SampleScriptableWizard.js




                            8
Find in Project!
 •   Demo




                   9
AssetPostprocessors
•       Super easy! Thanks Unity Tech.

•       Three main things:
    •   Asset path
    •   Reference to object
    •   Hooks

•       Good documentation




                                         10
EditorWindows
•   Super flexible.

•   If you can GUI it, you can Do-i it.

•   Example project in Unity’s Resources section.

•   GUI Editor, Node editor, Animation Curve editor.




                                                       11
That’s about it
 •   Four main types




                       12
The Facilitator
 •   Web level designer with server backend

 •   Quick demo




                                              13
Largest Challenges
 •   Lots of content!

 •   Realtime ready

 •   Getting references to content




                                     14
Solution #1
 •       Combine materials
     •   Each material is a draw call. Minimize these.

 •       Algorithm:
     •   Create small textures for solid colors.
     •   Tile out textures for UVs that go outside of 0..1
     •   Crop textures so only needed texture space is used.
     •   Draw out textures into one supertexture.
     •   Adjust UVs
     •   Save out to a .obj model and a texture

 •       “Magic menu item”



                                                               15
Solution #2
 •       Load arrays with a “MenuItem” editor script
     •   Update Units

 •       How:
     •   Walk through a set directory using .NET api
     •   Gather results
     •   SendMessage to a Managers object in the scene with the results.
     •   Managers script simply sets the data




                                                                           16
Problems...
 •   Teach the procedure to optimize.

 •   Writing user guides for clients == work.

 •   You have to remember things.

 •   We can do better.




                                                17
Dr. Improvements or: How I
Learned to Stop Worrying and
Love Unity 2.1
 •       Use AssetPostprocessors!
     •   Added in Unity 2.1

 •       Custom/Combine Materials -> OnPostprocessModel

 •       “Algorithm”:
     •   If assetpath starts with the path to our special models folder,
         perform combine materials postprocessing.




                                                                           18
Updating Arrays
 •       Throw menu item for dogs.

 •       OnPostprocessAllAssets!

 •       Four arrays of path strings

 •       Algorithm:
     • For each path in the importedAssets and movedAssets arrays,
      • Send an “add” message to Managers object if it’s in the right path.
     • For each path in deletedAssets and movedFromPath arrays,
      • Send an “remove” message to Managers object if it’s in the right
        path.

 •       No more fuss.

                                                                              19
That’s The Facilitator




                         20
RC Laser Warrior
 •   Simple RC car racing with powerups for the web.

 •   Regular new tracks

 •   Di erent car to unlock every day

 •   Published on shockwave.com

 •   Motion controller based version "Cars of Fury"




                                                       21
RC Laser Warrior
 •   Quick demo




                   22
Editor Related Challenges
 •   Download size (Three megabytes!?)

 •   Level creation

 •   Quality control: 79 levels to date




                                          23
Size Partial Solution
 •       AssetPostprocessor to the rescue! (partially)

 •       KillAllTangents.cs

 •       Tangents primarily used for bumpmapping.

 •       Zero 'em with an AssetPostprocessor!

 •       Algorithm
     •   If the assetPath contains one of our data paths, set each mesh's
         tangents to an array of the same size only containing all zeroes.




                                                                             24
Results
•   Knocks o a couple hundred kilobytes.

•   For free!




                                           25
Level Creation & QA
 •       Get into your level designer’s head.

 •       Automate placement of prefabs
     •   Keyboard shortcuts galore

 •       Visualize colliders
     •   CreateVisibleCollidersWizard.js




                                                26
Level Creation Demo
 •   Matt Gravelle, co-founder Graveck Interactive LLC




                                                         27
That’s RC Laser Warrior




                          28
Sooga Mountain Super Race
•   Downhill gravity racing with powerups

•   Built for Disney.com's JETIX games section

•   Localized

•   Three levels, four characters




                                                 29
Sooga Mountain Super Race
•   Quick demo




                            30
Editor Related Challenge
 •       3-4 minute levels

 •       Lots of placing things!
     •   AI Waypoints
     •   Pickups

 •       Solution:
     •   Prefab dropper

 •       Key:
     •   Abuse Static Variables




                                   31
Prefab dropper
 •   Quick demo




                  32
That’s Pucca.




                33
Benard's Honey Pursuit
 •   Four minigames with customizable avatar

 •   Built for Kraft/Post for Honeycomb Cereal




                                                 34
Benard's Honey Pursuit
 •   Quick demo




                         35
Two New Editor Uses
•       Copy bones
    •   Input source and destination, Apply, Done.

•       Export everything to .obj
    •   Lightmaps!




                                                     36
That’s Benard’s Honey Pursuit.




                                 37
Future Plans
 •       Biawesome GUI animations and layout.

 •       Possible Solutions:
     •   Cocoa-esque (Interface Builder)
     •   Code generation
     •   Rect editing and animation




                                                38
Rect editing and animation
 •   How to implement? Editor windows!

 •   Part 1: Visual editor for rects including nesting

 •   Part 2: Visual editor for animating rects

 •   “Coming soon”




                                                         39
Thanks!
•       Very near future: Editor Script Pack!
    •   Unity Resources Section

•       jon@graveck.com




                                                40

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:2
posted:2/24/2012
language:
pages:40