Archive

Archive for the ‘Windows Phone’ Category

Creating a Unity Game for Windows 8

August 30th, 2013 4 comments

UnityWindowsThe recent release of Unity 4.2 brings with it full-support for deploying Unity games to both Windows 8 and Windows Phone. Unity 4.2 is a powerful game development tool that comes in a free version and a Pro edition. The great news that comes along with the release of 4.2 is the ability to deploy your games to the Windows Store and Windows Phone Store free of charge! The Unity Windows Store Add-on is included in both the free version of Unity and Unity Pro.

To celebrate this announcement, Unity and Microsoft have teamed up to sponsor a Windows Build Competition with over $100,000 in prizes!!!

To get you well on your way to potentially winning a piece of that $100,000 prize pool, I’m going to walk you through the steps to build a Unity game for Windows 8.

Sign up with App Builder for access to additional resources, training and help building your Windows 8 game.

 

Let’s start simple

The purpose of this article is show you the steps to build your game for Windows 8. Not how to build the next Temple Run 2 – unfortunately. With that in mind, let’s start simple.

First download and install Unity. Unity comes in a free version and a Pro edition. The Pro edition provides more advanced game development capabilities. However, you can create some amazing games with the free version and I know several people who have done just that.

Once Unity is installed, open Unity and select File | New Project. Select a project location and choose not to import any packages at this time.

 CreateNewProject

You should now have a blank canvas to create your masterpiece. Fortunately for us, our masterpiece shouldn’t take us longer than 10 minutes to create.

Unity_Screen_1

In the Hierarchy window, select the Create dropdown and select Cube.

 

image

In the Inspector window, change the Scale and Rotation values to the following:

image

Your cube should look like the following. Slightly bigger than the default, turned to the left and tilted downwards.

image

If you click on the Game tab, you can see what your Cube will look like during runtime. Unfortunately, it’s a little dull and a little dark. Let’s add some lighting. In the Hierarchy window, select Create | Directional Light.

image

 

It doesn’t matter where the directional light is placed, what does matter is the angle it’s “shining” at. The Directional Light gives you the effect of a light shining from above at a specific angle that will highlight and generate shadows on the objects below.

image

You can switch to the Game window to see how your cube looks or even click the play button to see what your Cube looks like when your game is running. Although our cube is lit nice, its still pretty boring. Let’s add some animation to our cube.

To add an animation effect, we need to write some code. Unity supports your custom code to be written in JavaScript, Boo, or C#. At this time, JavaScript and Boo scripts won’t pass the Windows 8 Store certification. In addition, you can’t access C# classes from JavaScript and Boo, but you should be able to access JavaScript and Boo from C#. With all of that in mind, we’ll select C# as our script language of choice.

To create the C# script, select your Cube object in the Hierarchy window, and in the Inspector window, scroll all the way down and click the Add Component button and select New Script. Feel free to change the name of the script but be sure to select CSharp as the language. Click Create and Add. The will create a new Script object and place it in your Assets folder in the Project window. Also, with the Cube object selected in your Hierarchy window, you should see the script attached (checked) in the Inspector window.

image

To edit the script, you can double-click the script in your Assets folder (in the Project window) or double-click the script name in the Inspector window. The Update() method is called for every ‘Tick’ of game time. Essentially for every frame of your game.  In the Update() method, use the transform.Rotate() method to apply our animation.

image

You can control the speed of rotation through the multiplication value. The larger the value, the faster the rotation.

Save the script and switch back to Unity. To test your work of art, click the Play button. Congratulations, you have a spinning cube!

image

Click the play button again to stop the game from running. It’s important to stop before making any more changes to your project.

If you’re really adventurous, we could add a little more pizazz to our cube. In the Project window, right-click the Assets folder and select Import Package | Particles.

image

In the Importing Package window, leave everything selected and click the Import button. In the Project window, open the Smoke folder (Assets/Standard Assets/Particles/Smoke). Drag and drop Fluffy smoke onto the Cube in the Hierarchy window. Now, navigate to the Fire folder in the Project window and drag and drop Flame onto the Cube in the Hierarchy window.

Now when you press Play you should see a SPINNING CUBE OF FIRE!!!

image

Click the Play button to stop your – SPINNING CUBE OF FIRE! – and return back to the Unity editor. At this point, save your changes by selecting File | Save Scene (or CTRL-S). Now we’re ready to deploy our game to Windows 8.

Building for Windows 8

Open the File menu and select Build Settings. With Unity 4.2, we now have the ability to export our games to Windows 8 and Windows Phone. In the Build Settings windows, select Windows Store Apps and click the Switch Platform button. If your Scene isn’t already listed in the Scenes In Build list, click Add Current button.

Unity has the ability export your game into the following Visual Studio project types:

  • Direct 3D/C++
  • Direct 3D/C#
  • XAML/C++
  • XAML/C#

Which type you export to is more of a personal choice. Choosing XAML does add a slight performance hit to your game, but it does give you the capability to take advantage of rich UI and GUI elements for your game as well as easily take advantage of handling some Windows 8 scenarios such as Extended Splash Screens and Snapped View.

For our purposes, we’re going to select XAML/C# as our build type.

image

Unity gives us the capability to define the required Artwork for a Windows 8 app. Click on Player Settings… in the Build Settings dialog. In the Inspector window, you can specify elements such as Logo, Wide logo, Small logo, Splash screen, etc. If your game requires additional capabilities such as Internet Client connectivity or Location, you can specify these in the Player Settings as well. These settings are translated over to the Visual Studio project’s package manifest file (Package.appxmanifest).

 

image

Once you’ve completed setting your Player Settings and you’re ready to build your game, open the Build Settings window again (File | Build Settings), verify your scene is listed and the XAML/C# type is selected, and click the Build button.

If this is the first time you are building your game, Unity will prompt you for a build location. For my project, I created a ‘Export/Win8’ folder structure in my Unity project directory and selected the ‘Win8’ folder as my build directory.

Once the build is complete, open the generated solution file (.SLN) in Visual Studio.

image

If you’re a Windows 8 C# developer, this solution should look very familiar. Your Unity game and all of its assets are compiled and stored in the Data folder. Everything else is the Windows 8 application code that will host the Unity game. This structure preserves your Windows 8 application specific code from any changes made in Unity. When you make changes to your Unity game and re-export the build, those changes will only overwrite the contents in the Data folder. Everything else is preserved.

A Look Inside the Code

If you open the App.Xaml.cs file, you can examine how the Unity player is integrated into this XAML/C# application.

At the beginning of the App class declaration, there are two class variables declared:

private WinRTBridge.WinRTBridge _bridge;
private AppCallbacks appCallbacks;

WinRTBridge is a Unity internal-only class that provides Unity the integration between the managed and unmanaged world. It is not intended to be used by developers.

AppCallbacks is a very important class. This class provides the developer’s bridge between the Windows 8 application and your Unity game. The AppCallbacks class is used to initialize your Unity game at start-up time as well as handle events between the Windows 8 application and your Unity game. More details can be found in the Documentation for AppCallbacks.

In the MainPage.xaml file, the Unity player is hosted in a SwapChainBackgroundPanel control. This controlled is initialized and loaded in the OnLaunched() event defined in App.xaml.cs.

Other than those custom elements required by Unity, this is just a standard XAML Windows 8 application. The Unity documentation does contain several samples on how to integrate your Unity game with your Windows 8 application. Included in those samples, is the XAMLUnityConnectionV4 sample that shows how to integrate event-handling between Unity and your Windows application. This is necessary to handle events such as the user switching your game to snapped view as well as any GUI related events triggered by XAML that need to be sent to Unity. Another sample worth noting is the MetroSettingsMenuV1 sample that shows how to integrate the use of the Settings menu in Windows 8 with your Unity game.

At this point, you can test your game as a Windows 8 app by clicking the Run button (or hitting F5) in Visual Studio.

Note: Your app may fail deployment because of…

Error: DEP0700: Registration of the app failed. Windows cannot install package MyWindows8Game because the package requires architecture ARM, but this computer has architecture x64 (0x80073cf3).

The Unity exported project contains a build configuration definition for ARM, x64 and x86. Your most likely not developing on an ARM based machine, therefore you need to change the current building configuration to test your game on your development machine. To do this, open the Build menu in Visual Studio and select Configuration Manager. In the Configuration Manager window, select appropriate architecture under Active solution platform.

image

Close the Configuration Manager window and re-run your application by clicking the Run button (or F5).

image

Congratulations! You’ve built a Unity game for Windows 8!

Here is my completed project in-case you missed a step along the way:
FireCube.zip.

 

Bringing it Home

There are some additional elements you’ll need to be aware of to get your Unity game through the Windows Store certification process. Much of this guidance is available from the Building Windows Games with Unity event held last spring. Here experts from Unity and Microsoft share insight, guidance and lessons learned to bring your Unity games to Windows 8 and Windows Phone.

Jodon Karlik, of CodingJar, has an invaluable session on the lessons he learned when building Fling Theory for the Windows Store. These lessons include implementing an Extended Splash Screen, conditional compiling, Ad integration and handling snapped view. Also recommended is the session from Vladimir Kolesnikov on Differentiate: Integrate your game with Windows 8 Platform Features, which delves into topics such as contracts, notifications and live title integration. Also, be sure to read through the Windows Store and Windows Phone sections of the Unity documentation for all the latest in support and capabilities.

The last step is to package up your game using Visual Studio and to follow the publishing guidance.

The time is right for success in the Windows 8 Store. Unity provides every budding and professional game developer the high quality tools to build amazing games. With the latest release of Unity 4.2 you now have the power to bring those games to the Windows Store and Windows Phone Store.

Event: Windows Phone 7.x Upgrade Lab

April 5th, 2013 No comments

Windows Phone 8 offers up some exciting new features and opportunities for developers. The customer base is getting larger with new form factors and low-memory devices. Is your app ready? Are you ready to add the new Windows Phone 8 features to your existing 7.x app? Do you understand the key scenarios to make your app shine on Windows Phone 8 and bring nothing but 5-star reviews? The Windows Phone Evangelism team at Microsoft is hosting a Windows Phone 7.x Upgrade Lab to help you make your app shine on Windows Phone 8.

What is a Windows Phone Upgrade Lab?

The Windows Phone Upgrade Lab is a free, fun, no-fluff workshop for Windows Phone Developers by Windows Phone Developers. Our Technical Evangelist team will introduce you to the new features in Windows Phone 8 and what you, as a Windows Phone Developer, need to do to take advantage as these features. We will also guide you along the path of making your app work great across the new form factors and low memory devices coming from the many Windows Phone manufactures.


Location Date
Columbus, OH 5/3
Chicago, IL 5/7
Edina, MN 5/7
Indianapolis, IN 5/9

What can I expect?

The Windows Phone Upgrade Lab is a working lab. This means, bring your development machine and your source code and be ready to submit your Windows Phone 8 updates by the end of the day. We will start off the day by discussing the new developer features of the Windows Phone 8 SDK. Following this, our technical experts will be on-hand to assist you in bringing some of these features to life in your app. We will help identify what features would be best utilized in your app, help you implement those features, and assist you in submitting your app into the store by days end. We will cap off the day by introducing you to strategies for bringing your app to Windows 8 and opening up your app to a whole new world of new customers!

Some of the features we’ll be discussing, include…

  • New Windows Phone 8 Features
  • What is the Windows Phone Runtime?
  • What’s new in Tiles and Notifications
  • Handling Multiple Resolutions
  • Understanding the required artwork
  • New Proximity Scenarios with Bluetooth and NFC
  • New Mapping technology from Nokia
  • Lock Screen integration
  • How to start thinking of bringing your app to Windows

Notes:
1. Download and Install the Windows Phone 8 SDK at http://aka.ms/Phone8Tools

2. The Windows Phone 8 SDK Emulator requires your machine to support SLAT (Second Level Address Translation). You can verify if your machine supports SLAT by running the CoreInfo tool. More information can be found at http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj863509(v=vs.105).aspx.

If your machine does not support SLAT, you can still use the SDK and test against a physical Windows Phone Device. If you don’t have a Windows Phone 8 device, we will have some on hand during the workshop to test with.

3. You can get a jump start on the workshop by working through the tutorials in the Windows Phone 8 Training Kit or playing around with the many Windows Phone Code Samples.

In addition to registering for this Workshop, be sure to take advantage of great resources such as access to free expert guidance, app and game frameworks, as well as free storage and tools with Generation App! Sign up at http://aka.ms/AppFor8.

Categories: training, Windows Phone

Event: Building Windows Games with Unity

March 30th, 2013 No comments

Are you ready to bring your Unity game to Windows and Windows Phone? Do you want to learn more about the recently announced Unity support for Windows and Windows Phone?

Unity and Microsoft are holding a free, two-day training event designed to help you bring your Unity games to the Windows Platforms. Although this event is taking place in Mountain View, CA, those great folks at Channel9 will be broadcasting the Main Event on Tuesday, April 9th.

Main Event Agenda:

  • Introduction to the Windows 8 Platform and the Windows Store.
  • End-to-End: Develop, debug and deploy a Unity game for the Windows Store.
  • Deep dive: Tips & tricks for porting games from other platforms to Windows 8.
  • Differentiate: Integrate your game with Windows 8 platform features (such as contracts, notifications, and live tiles).
  • Sharing code: Learn how to reuse all this new knowledge on the Windows Phone platform.
  • Partner sessions: Hear the lessons learned from those that have already done it.

Building Games with Unity
Tuesday, April 9-10 (Pre-event training on April 8th)
Register to attend in-person

Channel9 Broadcast

Unity Beta for Windows Store and Windows Phone Open!

March 28th, 2013 No comments

On Wednesday at the Game Developer Conference, Unity announced the beta for Unity 4 for Windows Phone is now open! This is in addition to the open beta for Windows Store apps.

There are currently a few titles on Windows Phone that have been using the early bits of Unity. They include…

Drift Mania Championship 2

Fling Theory

Orcs Must Survive

Unity provides an easy to jump-in toolset for budding game developers and provides the rich-feature set required by seasoned professionals. Unity democratizes game development. With the addition of this support for both Windows Phone 8 and Windows Store apps, you have the opportunity to bring your game titles to Windows XP/7/8, Windows RT, and Windows Phone 8.

I, myself, am a want-to-be-game-developer and have been personally working with Unity to scratch this game development itch I’ve been fostering for many years. I am learning a ton from the recently released Tutorial Modules from Unity. If you just want to jump in and see what this Unity thing is all about, check out Learn Unity Game Development in 10-minutes from Primer Labs.

If you’re an existing Unity developer and would like help porting your game to Windows 8 and/or Windows Phone, feel free reach out and I’ll see what I can do to help you.

The first Unity Game hits the Windows Phone Store!

March 13th, 2013 No comments

I happy to report that, Drift Mania Championship 2 from Ratrod Studio Inc., has just published the first Windows Phone game built with the Unity SDK. I’ve already bought and am learning the ins-and-outs of drift racing on my phone. The graphics are fantastic, the physics are amazing, and the performance is top notch. You need to check this out!

 

Drift Mania Championship 2

Drift Mania Championship 2

image

If you are a Unity developer and would like help bringing your game to either Windows 8 or Windows Phone (or both!), feel free to grab some of my time and let’s make it happen!