380 likes | 495 Views
Tales from the trenches: Developing “The Harvest” and “Gunpowder” with Unity. Ethan Abeles – Senior Producer, Microsoft Studios Richard Sun – Co-Founder and Lead Programmer, Rogue Rocket Games 3-044. Agenda. Introductions Why make games for Windows 8?
E N D
Tales from the trenches:Developing “The Harvest” and “Gunpowder” with Unity Ethan Abeles – Senior Producer, Microsoft Studios Richard Sun – Co-Founder and Lead Programmer, Rogue Rocket Games 3-044
Agenda • Introductions • Why make games for Windows 8? • Demo: See what we’ve done! • Why Unity? • How Unity? • Tips and tricks • Thinking about the future
Ethan Abeles – Senior Producer • “I’m not only a producer, I’m also a client!” • Part of the Connected Experience Team, focused on bringing cool, new content to Microsoft’s latest platforms • Working to build out the content on the platform and push the platform to be the best it can be for gaming partners • Wanted to move to where games are evolving more quickly • Needed a quick and cheap way to produce prototypes and demos • Looking to work with developers comfortable in the mobile space • Released 2 Unity for Windows 8 games
Richard Sun – Co-Founder, Rogue Rocket Games • 11-year game-development veteran • Planet Moon Studios – Lead programmer • LucasArts Entertainment – Programmer • Shipped many titles on many platforms, both big and small • Developed games in teams of various sizes and product scopes • Specializes in rapid prototyping and development • Great hair • Released 2 Unity for Windows 8 games • And in this corner, representing the fantastically creative, super agile, indie game studio…
We are real-world clients and users of Unity. We cut our teeth during the Alpha days of the Windows 8 branch and we’ve come to here to tell you tales, tips, and tricks from the frontlines.
Why make games for Windows 8? • New Store = less competition • Developer-friendly environment • User base growing every day • Users hungry for content • Industry leading revenue splits!
But there are a few hurdles… • New Store = initially small user base • Windows Store discovery and layout • Thankfully, as you’ve seen this week, Microsoft is working hard to fix those issues and make the platform a great place to sell games.
Windows 8 and Unity • Why build with Unity? • All of the great Unity tools you’re used to are ready to go out of the box • Unity’s multiplatform approach is great for modern game development and release • Quickly port existing projects to Windows 8
Okay, so how does Unity for Windows 8 work? • Unity on Windows 8 is a bit different. • Unity provides a Visual Studio 2012 Project • Similar to how Unity handles iOS projects/xCode • This is actually awesome and we’ll talk about it shortly • Unity runs on the .NET Framework – Not Mono • We’ll talk about what that means in just a bit. • Unity games for the Windows Store can consume only Windows Runtime Components (no unmanaged DLLs) • This can come into play when you try to use Unity plug-ins
Those caveats aside, it’s still the same awesome Unity being used to make new and innovative Windows 8 games.
And we aren’t the only ones using Unity. As of mid-May there are a bunch of awesome games in the Windows Store >30 Games
So what should I know about my workflow? • Use the Unity editor as you always do • Have Unity generate a Windows 8 Visual Studio project • Extend your application to take advantage of the fun Windows 8 features you’re hearing about in the other //BUILD talks • Debug directly from within Visual Studio or build an app package for sideload testing • Unity workflow on Windows 8 should be familiar for anyone who has built iOS applications using Unity
Wait, did you say I get to use Visual Studio? • Yes we did! • The Windows and Visual Studio teams created and massively improved the tools developers have for authoring, debugging, and previewing DirectX code. This makes everyone happy! David, on using MonoDevelop David, on getting to edit and debug in Visual Studio
Tips and tricks for making your life easy! • Make loading times interesting • Script builds with MSBUILD • Windows 8 delegates • Component caching • Object pooling • Avoid CPU-intensive components • Tips for porting
Tip #1 – Making loading times interesting • Use a XAML layer to do cool things during loading time • Players don’t like looking at static screens • Two ways to do this: • XAML – Use <Storyboard> and Animations • WMV – Use <MediaElement> with a WMV file • Both options make use of a XAML page built in Visual Studio • Use Unity to call out to your XAML class to show/hide/collapse these XAML views
Tip #2 – Script builds with MSBUILD • If you’re working with a publisher or partner, script your build process to save clicks/time! • Visual Studio won’t “queue” up multiple configurations when building app packages • PowerShell is your friend • MSBUILD: Awesome, complicated, and slightly under-documented • Build from the command line with following code
Scripts for building app packages • start msbuild /p:Configuration=Release /p:Platform="ARM" • choice /t 5 /c yn /d y • start msbuild /p:Configuration=Release /p:Platform="x86"
Tip #3 – Talking between Unity and the Windows Runtime • You can now use plug-ins but that wasn’t ready for us so we used delegate registration • You’ll want to have Unity talk to the OS to do this, so you’ll do two things: • Define the delegates in Unity • Implement them on the Windows 8 C# side
Tip #3 – Talking between Unity and the Windows Runtime • Unity3D side C# • public delegate void Win8ShowPopupFunc(string title, string desc, System.Action onDismiss); • public delegate void Win8ShowYesNoPopupFunc(string title, string desc, System.Action onDismiss); • public static Win8ShowPopupFunc _ShowPopup = null; • public static Win8ShowYesNoPopupFunc _ShowPopup = null; • Windows 8 side C# • RRGMetroBridge._ShowPopup = ShowGenericPopup; • RRGMetroBridge._ShowYesNoPopup = ShowYesNoPopup;
Tip #4 – Component caching • Use component caching to minimize interop overhead • ~95% of Unity’s engine code is in C++ but we, as users, interface with the engine in C# • Interop between managed and native code is expensive, so… • Code wisely and minimize the Unity APIs you call each frame, including component references
Tip #4 – Component caching • BAD • public class example: MonoBehavior { • void Update() { • transform.Translate(0, 0, 5); • } • }
Tip #4 – Component Caching • TERRIBLE • public class example: MonoBehavior { • void Update(){ • for (int i = 0; I < 1000; ++i) { • myTransform.Translate(0, 0, transform.position.z + 0.005f); • } • } • }
Tip #4 – Component Caching • GOOD • public class example: MonoBehavior (Transform transform) { • private Transform myTransform; • void Awake(){ • myTransform = transform; • } • void Update(){ • myTransform.Translate(0, 0, 5); • } • }
Tip #5 – GameObject pooling • Instantiating and destroying GameObject objects is expensive • Rather than creating and destroying objects at will, create a basic pooling system that: • Keeps track of free/inactive objects • Has methods for reusing/resetting objects quickly • For extra brownie points, implement a more granular pooling system that pools objects of the same or similar type, so reconfiguration/reuse cost is minimized
Tip #5 – GameObject pooling • Instead of destroying GameObjects: • gameObject.SetActive(false); • MyPoolManager.AddToFreePool(gameObject); • Instead of instantiating: • GameObject = MyPoolManager.GetFreeObject(); • SetupObjectDefaults(gameObject); • gameObject.SetActive(true);
Tip #6 – Budget CPU-intensive components • Remember that Windows 8 is supported by a huge range of hardware, both super fast and low power consumption • Use with caution: • Intense desktop shaders • Unity terrains • Real-time shadows • Dense particles • Non-tessellated sprites • *This list might change as hardware evolves
Tip #7 – Notes for porting • If you’re bringing a released app to Windows 8… • Think about mouse + touch • Input.Touch vs. Input.Mouse • Input.simulateMouseWithTouches • Native code plug-ins will need to use Windows Runtime APIs • Convert HashTable and ArrayList to Dictionary • Keep native-code version of API (which stubs Windows Store functionality) for use in the Editor’s Play Mode • Check the API lists located on the resource slide • How can you tell if a plug-in uses an unapproved API? Use the Windows App Certification Kit
What other knowledge can you share? • We can show you scars! • Windows App Certification Kit • Gives you a quick Windows Store compliance test • CurrentApp vs. CurrentAppSimulator • The real licensing API vs. the testable license API • Make sure you #IFDEF all calls • SoC processing power considerations • Load times, Fullscreen FX, too many draw calls, complex shaders
What other knowledge can you share? • Ratings + GDF files • If you want to submit a game to the Windows Store, you must provide metadata that defines the ratings for your game as part of the game package. • Some territories require ratings for games • Some territories use self-ratings systems • These files allow parents to use the Family Safety features of Windows. Happy parents mean happy consumers!
What other knowledge can you share? • Live tiles are awesome, unique and powerful • Make use of Live Tiles to drive retention and increase conversions • Sales / Limited-time discounts • F2P discounts • Limited-time in-game events • Multiplayer invites • Multiplayer turn notifications • Other calls to action
Thinking about the future – Up, Up and Away! • Things are going to get even better? • Windows 8.1 – Making the marketplace even better • New hardware – Greater performance from new hardware • Unity optimizations – Continued work on optimizing Unity for Windows 8 shows great promise
Resources – Unity documentation • Mobile Optimization Tips • http://docs.unity3d.com/Documentation/Manual/MobileOptimisation.html • Optimizing Graphics Performance • http://docs.unity3d.com/Documentation/Manual/OptimizingGraphicsPerformance.html • Practical Guide to Optimization for Mobiles • http://docs.unity3d.com/Documentation/Manual/iphone-PracticalGuide.html
Resources – Windows 8 & Windows Runtime • Disallowed .NET APIs • http://msdn.microsoft.com/en-us/library/windows/apps/xaml/br230302.aspx • Allowed win32 APIs • http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx • Replacing disallowed win32 APIs • http://msdn.microsoft.com/en-us/library/windows/apps/hh464945.aspx • Windows 8 & Windows RT hardware compatibility FAQhttp://www.microsoft.com/en-us/windows/compatibility/win8/compatcenter/faq
Resources – Other videos/presentations • Channel 9 – Windows 8 / Windows Phone and Unity presentations • http://channel9.msdn.com/Events/Windows-Camp/Building-Windows-Games-with-Unity • Covers what we’ve covered in a lot more detail! • Featuring : • Platform introduction • End-to-end develop, debug, and deploy • Tips & tricks • Windows 8 platform usage • … And an awesome talk by our very own Richard Sun!