Presented at SCREENS 2013 in Toronto.
Details at fitc.ca/screens
Unity has quickly become the go to tool in the indie game scene. The recently announced partnership between Microsoft and Unity has made it more even more enticing. Offering free plugins for both Windows 8 Store apps and Windows Phone 8, Unity and Microsoft have created a simple, cost effective solution for developers to bring their creations to the Windows ecosystem. In this session we will take a look at the process of porting a Unity game to the Windows 8 platform, highlighting the key features and possible pain points with simple to follow examples.
15. • Took a game with simple input (non-multi touch) and
adapted it for the Windows 8 and Windows Phone Stores
with no code changes
• Viewed the settings available when building the game
• Created a Visual Studio Solution for our game
16.
17. • An easy way to setup snap view in your Unity project
• How to connect to and work on the games assembly in
Visual Studio
18.
19.
20.
21. • An easy way to handle the back button presses in your
Unity project
• Where the splash screen and the game tile (app icon)
images can be found.
22. • Start playing with and learning the exciting advanced
features of Unity (unity3d.com/learn)
• Enhancing your game with some of the Windows 8 and
Windows Phone platform features like:
Tiles & push notifications
Splash Screen Image
Share and Search
• Bring your game to the Windows Store and become
famous (buildforwindows.ca)
This presentation is not intended as an intro to Unity, I am assuming you have experience with Unity.
Windows 8 and Windows Phone with there stores lets youdistribute your apps to millions of users world wide. This is a great opportunity for you to expand your games to more markets and of course increase sales.
Althoughit is fairly simple to get your game ready for the Windows 8 and Windows Phone stores, there are steps you will need to take.
So today we are going to take sometime and look at these steps and hopefully by the end you will have a good understanding of how to get your Unity game ready for the Windows 8 or Windows Phone store
Here is our agenda for todayFirst off we are going to a closer look at unity and Windows Phone, followed by a closer look at unity and Windows 8Then we dig in and learn how to get our game code out of unity and into visual studioAfter that we will take a look at the steps you need to take to get ready for the storeYou can find the game code I use here (https://github.com/ScruffyFurn/RectangleDestroyer)
Most the issues I have been running into are in plugins. This due in part to the fact that they are calling a Mono API that is not in the phone. The compiler might not catch these and can lead to exceptions when running on the phone. A good tool to validate an assembly’s portability to Windows Phone is http://scan.xamarin.comIf you find errors or missing Mono APIs that you are using in your game, you should look at the .NET API for Windows Phone (http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207211(v=vs.105).aspx) reference site to find alternates.
Unity 4.2 (http://unity3d.com) Either the Unity free version or Unity Pro will work. The add-ons to publish to Windows Phone and Windows Store are free, even for Unity Pro users.Windows Phone SDK 8.0 The WP8 SDK includes a stand-alone version of Visual Studio Express 2012 - if you already have Visual Studio Premium or Ultimate, the SDK will work as an add-in. (http://dev.windowsphone.com/en-us/downloadsdk)Windows 8.0 or later. If you do not own a Windows 8 license, you can get a 90-day evaluation version. If you are running Mac OS X or will install on Apple hardware, check different options for installing using Boot Camp, or Parallels.Windows Phone developer account. This is needed to “unlock” your phone so you can side load your game for developing and testing. It will also be needed to submit your game to the Windows Phone store. (http://developer.windowsphone.com/)Windows Phone 8 device. In Unity 4.2, deploying and debugging to the Windows Phone emulator is not supported, so you will need a phone.
Unity 4.2 Either the Unity free version or Unity Pro will work. The add-ons to publish to Windows Phone and Windows Store are free, even for Unity Pro users.Visual Studio I suggest Visual Studio Ultimate or Premium , but Express will workWindows 8.0 or later. If you do not own a Windows 8 license, you can get a 90-day evaluation version. If you are running Mac OS X or will install on Apple hardware, check different options for installing using Boot Camp, or Parallels.Windows Store developer account This will be needed to submit your game to the Windows 8 store.
We saw how we can take a game with simple input (non-multi touch) and adapt it for the Windows Store with no code changesWe took a look at the some of the settings available when actuallybuilding the gameWhile we are at it we also took a quick look at changing the logos to give our game the polished look.And Finally we created the Visual Studio solutions for our game.
So now that we have our solution created lets fire it up and take a look at how to add some must have features for our game to pass certification and make it to the store.
II have already setup a few things in the game code to pause the game. Specifically I have created a Boolean value that we can set to pause the game. The following steps will show you one way to handle the change in size:1. In our App.xaml.cs file we need to add using statement, “using Windows.UI.ViewManagement;”2 .Next we need to add an event handler for when the window changes size. Add the following to the bottom of the OnLaunchedfuction: Window.Current.SizeChanged += WindowsSizeChanged;3. Finally we add a simple function to change the value of the Boolean variable to simply pause the game when we are in snap view. Below is that function void WindowSizeChange(object sender, WindowSizeChangedEventArgs e) { if(ApplicationView.Value == ApplicationViewState.Snapped) {BreakoutGame.SP.snapView = true; } else {BreakoutGame.SP.snapView = false; } }
Proper handling of the back button is a certification requirement. If you do not handle it, you will fail certification.
Like before I have done a little prep work. I added a function that when called will exit the game. This is not a best practice, it is meant to be just a simple example to show you how to hook up the button pressedMost of the work is done for us. If we open the MainPage.xaml.cs file and scroll to the bottom the file you will find the PhoneApplicationPage_BackKeyPress function. This function is the handler for when the back button press and is where you can add your code for when the button is pressed. In my case I simply call the quit function of the game, again not a best practice While we are here lets go ahead and take a look at where the game tiles(app icons) and splash screen image files are located. Inside the solution explorer if you open the Assets folder there is a Tiles folder that holds all the images for the tiles. The splash image, SplashScreenImage.jpg can be found in the root folder
Well today we have looked at quite a bit and you might be thinking where do I go next.One of the best ways to learn the new features of a tool is through exploring it. unity3d.com/learnIf you haven’t already go and download Visual Studio, if you have a DreamSpark (https://www.dreamspark.com/)or a BizSpark (http://www.microsoft.com/bizspark/) slash MSDN (http://msdn.microsoft.com) accountyou can get Premium or Ultimate through those accountsFinally build your game and bring it to the Windows store platform, become rich and famous and thank me in your fortune magazine article for being your inspiration buildforwindows.ca
Developer Movement is a Canada exclusive Developer Loyalty Program. Here developers get points for developing Windows 8, Windows Phone, and Windows Azure apps, every step of the way. Get points for publishing, and doing other things like Azure labs. At any time, you can cash in on your points to get awesome rewards like an Xbox 360 Kinect, Digital SLR, or even a TV.
Well I hope you have learned a little and maybe even got a little inspiration from this presentationThank you very much for coming and happy coding