Unite 2011 Scalable Game Development

58
William Roberts Ryan Hipple Scalable Game Development

Transcript of Unite 2011 Scalable Game Development

Page 1: Unite 2011 Scalable Game Development

William RobertsRyan Hipple

Scalable Game Development

Page 2: Unite 2011 Scalable Game Development
Page 3: Unite 2011 Scalable Game Development

3

Page 4: Unite 2011 Scalable Game Development

William RobertsSenior Game Engineer

Schell Games – www.schellgames.com

Scalable Game Development

Page 5: Unite 2011 Scalable Game Development

The Monolithic Project

• Takes an extremely long time to import assets.

• Editor becomes unstable as the project size grows.

Page 6: Unite 2011 Scalable Game Development

Unity Projects

Art Pipeline Code Build Tools

Scalable Game Development

Page 7: Unite 2011 Scalable Game Development

Unity Project Structure

Unity Projects

Page 8: Unite 2011 Scalable Game Development

Typical Directory structure

Unity      Entry Point Project      Project A      Project B      Project etc...  Code      DLL Library Project A      DLL Library Project B      DLL Library Project etc...BuildTools

Page 9: Unite 2011 Scalable Game Development

'Entry Point' Project

• A single scene with a “main” game object.

• All of the DLL’s needed to run and build the game.

• A minimal amount of assets in the “Resources” directory.

Page 10: Unite 2011 Scalable Game Development

• Content is split into multiple Unity projects.

• Each project contains a copy of the dll's.

• Similar assets are grouped together.• All assets are packaged into asset

bundles.• Easy to rebuild portions of the project.

Content Projects

Page 11: Unite 2011 Scalable Game Development

Art Pipeline

Unity Projects

Art Pipeline

Page 12: Unite 2011 Scalable Game Development

Art Pipeline - Pros

• Only artists need copies of 3rd party art tools installed.

• Faster import times. • Asset Database becomes

corrupted less frequently.

Page 13: Unite 2011 Scalable Game Development

• Goes against the standard Unity work flow.

• Causes some extra work for the 3D artists.

Art Pipeline - Cons

Page 14: Unite 2011 Scalable Game Development

Code Projects

Unity Projects

Art Pipeline Code

Page 15: Unite 2011 Scalable Game Development

Project Code Base - Pros• Reusable core framework that

can be shared between projects.• Ability to use namespaces.• Custom compiler preprocessor.• Easily obfuscate code using

professional tools.

Page 16: Unite 2011 Scalable Game Development

• Some of the Unity API methods no longer work as expected.

• MonoBehaviour visibility in inspector can become broken in certain scenarios.

• Editor cannot display source code documentation.

• May not play nice with certain export options (ie: Export to Flash).

Project Code Base - Cons

Page 17: Unite 2011 Scalable Game Development

1) Programmer selects “Build Solution” within the development studio of their choice.

2) A special tool is executed to copy the projects output if the build was successful.

3) Each assembly and debug database is automatically copied into each Unity project.

Code Build Process

Page 18: Unite 2011 Scalable Game Development

IDE Differences• Build Events are not the same as Custom

Commands.• Visual Studio

Build Events are essentially bat files that can be executed before or after a build.

Page 19: Unite 2011 Scalable Game Development

IDE Differences• MonoDevelop Custom Commands are

single commands that are executed before or after a build.

Page 20: Unite 2011 Scalable Game Development

IDE Differences• Both MonoDevelop and Visual Studio will

attempt to insert the same target import using a different Environment Variable into the C# project file.

Page 21: Unite 2011 Scalable Game Development

Debug Databases

• The  program database (PDB) file is an proprietary format developed by Microsoft.

• The mono team decided to create their own format (MDB).

• We need to generate MDB files in order to debug our assemblies.

Page 22: Unite 2011 Scalable Game Development

OSX• MonoDevelop is setup out of the box.

Windows - 2 ways to make this work: • Download and install the official Mono

SDK (Easiest way)• Modify the MonoDevelop configuration

files to point to Unity’s Mono directory.

Debugging External Assemblies

Page 23: Unite 2011 Scalable Game Development

The Easy Way1) Grab  a copy of the Mono SDK from the

official website. I would recommend using v2.6.1.

http://mono-project.com/OldReleases2) Launch MonoDevelop and navigate to the

“Tools->Preferences” menu.

Page 24: Unite 2011 Scalable Game Development

The Slightly Harder Way1) Navigate to MonoDevelop configuration directory:

Windows XP: C:\Documents and Settings\{UserName}\Application Data\MonoDevelop-Unity

Windows Vista & 7: C:\Users\{UserName}\Application Data\MonoDevelop-Unity

2) Create a new file in the directory named mono-runtimes.xml and copy the following XML into it:

Note: If your Unity installation directory is non standard, you will need to change the path to reflect your own installation.

Page 25: Unite 2011 Scalable Game Development

3) Open the "MonoDevelopProperties.xml" file and locate the "MonoDevelop.Ide.DefaultTargetRuntime" property.

4) Change the value to be "Mono Unknown".

5) Save the changes to the file.

The Slightly Harder Way

Page 26: Unite 2011 Scalable Game Development

The Slightly Harder Way

Page 27: Unite 2011 Scalable Game Development

1) Open the Unity Project you wish to debug.

2) Open MonoDevelop and load the Solution file for the .NET Library Projects.

3) In the  MonoDevelop IDE Select "Run->Attach To Process".

Debugging Projects

Page 28: Unite 2011 Scalable Game Development

4) Select the Unity Editor process and click the "Attach" button.

5) Set breakpoints in your code.6) Finally click the "Play" button in the Unity editor!

Debugging Projects

Page 29: Unite 2011 Scalable Game Development

Build Tools

Unity Projects

Art Pipeline Code Build Tools

Page 30: Unite 2011 Scalable Game Development

Build Manager

Page 31: Unite 2011 Scalable Game Development

• Built on top of Microsoft .NET Framework. • Utilizes the MSBuild API to build Visual Studio

solutions and projects.• Launches Unity in command line mode to build

each projects asset bundles.• Monitors the Unity Editor log file for changes and

displays it in real time.• Features an XML script file that allows us to

customize the build process. Pre-build and post-build commands can be issued.

Build Manager

Page 32: Unite 2011 Scalable Game Development

Asset Bundle Builder

Page 33: Unite 2011 Scalable Game Development

Thanks!

William [email protected]

http://www.williamroberts.net

Page 34: Unite 2011 Scalable Game Development

Ryan HippleGame Engineer

Schell Games – www.schellgames.com

Scalable Game Development

Page 35: Unite 2011 Scalable Game Development

Multi-platform

Externalizing Data

Better OnGUI Editor Tools

Scalable Game Development

Page 36: Unite 2011 Scalable Game Development

Multi-platform Development

Multi-platform

Page 37: Unite 2011 Scalable Game Development
Page 38: Unite 2011 Scalable Game Development

Screen Resolutions

480x320

960x640

800x480854x480760x456

Page 39: Unite 2011 Scalable Game Development

Dynamic Rectangle

• Percentages• Parenting• Anchoring• Min / Max values

Page 40: Unite 2011 Scalable Game Development

#if

#if UNITY_ANDROID

#if UNITY_WEBPLAYER #if UNITY_IPHONE

#if UNITY_WEBPLAYER && ! UNITY_EDITOR

#if UNITY_ANDROID || UNITY_IPHONE && !UNITY_EDITOR#if UNITY_WTF

#if UNITY_EDITOR

Page 41: Unite 2011 Scalable Game Development

Externalizing Data

Multi-platform

Externalizing Data

Page 42: Unite 2011 Scalable Game Development

Externalizing Data

• Const files• Game Object + Inspector• ScriptableObject

Page 43: Unite 2011 Scalable Game Development

Defining a ScriptableObject

Page 44: Unite 2011 Scalable Game Development

Creating a ScriptableObject

Page 45: Unite 2011 Scalable Game Development

Loading a ScriptableObject

• Reference in Inspector• Resources.Load• Singleton with Resources.Load• Asset Bundle

Page 46: Unite 2011 Scalable Game Development

What do I put in there?

• Config Data• Designer Data• Localized text• GUI Data

Page 47: Unite 2011 Scalable Game Development

Better OnGUI

Multi-platform

Externalizing Data

Better OnGUI

Page 48: Unite 2011 Scalable Game Development

Separate the Layout

• Each ”UI Page” gets a corresponding layout class• ”UI Page” loads layout object and uses it to draw• Tweak in inspector• Make an artist do it

Page 49: Unite 2011 Scalable Game Development

Separate the Styles

• Same as layout, but with GUIStyles• Each UI Page gets a class defining a list of GuiStyles• Organize GUIStyles in groups• Reduce GUISkins

Page 50: Unite 2011 Scalable Game Development

Why not GUISkins?

• ”Custom Styles” do not scale well• Source control• Slow to edit• No Sorting

• String lookup• No auto-complete / checking• Slow

Page 51: Unite 2011 Scalable Game Development

35% Faster

Page 52: Unite 2011 Scalable Game Development

Video Demo

Page 53: Unite 2011 Scalable Game Development

Separate the Content

• I Already told you how to create it• Now you know how to display it• Tweak it with the Inspector... right?

Page 54: Unite 2011 Scalable Game Development

Editor Tools

Multi-platform

Externalizing Data

Better OnGUI Editor Tools

Page 55: Unite 2011 Scalable Game Development

Building Design Tools

Awesome Juice

Programmer Tears

Page 56: Unite 2011 Scalable Game Development
Page 57: Unite 2011 Scalable Game Development

• Designer independence with tools• Artist independence with UI separation• Code flexibility from data externalization• Streamline multi-platform development

Scalable Game Development

Page 58: Unite 2011 Scalable Game Development

Thanks!

William Roberts - [email protected] Hipple - [email protected]

slides – unite.schellgames.com