Unity for Windows:ii–publishing Unity games to Windows Store

Source: Internet
Author: User

Original address: http://digitalerr0r.wordpress.com/2013/08/27/unity-for-windows-ii-publishing-to-windows-8/

Windows 8 is a new OS with a Windows Store where can distribute your apps to millions of the users world wide, for both PC , laptops and tablets.

You can sell your apps, use In-app purchases Or/and with ads to monetize!

(Publishing to Windows Phone 8 'll be covered in part III)

Today we are going to export the game we created in part I of the tutorial as a Windows Store solution this runs on all de Vices using Windows 8.

Start with opening the game from part I (download here) in Unity and check if it runs like it should (open Gamescene and R Un the game).

You should is able to play and come to the game over screen if a invader gets to the left side of the screen.

Download:tutorial Part II Assets

I. Handling the snapped view (snap view)

To make your game pass the Windows Store certification (so it gets publishes), we need to handle snapped view mode in our U Nity Game–when the player decides to snap the game of the side of the.

What's games got in common are that it's hard-to-play in Snap mode (really just a resolution change).

A Common-handle snap mode is by simply pausing the game! But what do we pause the game? Let's write a script that sets the game in Pause–and that'll be invoked from the exported solution we soon would create .

Add a new Script to the Scripts folder

Using Unityengine;
Using System.Collections;

public static class Windows8handler {
public static void Pausegame (BOOL p)
{
if (p)
{
Time.timescale = 0.0f;
}
else Time.timescale = 1.0f;
}
}

This function was a public static function–we can call it from wherever we want and don ' t need to create an instance of T He class to use it.

Ok! This is all we need from Unity, and the next step in handling snap view would be from the exported solution.

II. Getting ready to export the Windows Store App

Create a new folder named Publishing in the Assets folder and add the three logos textures for our game (you can find them In the assets zip for this tutorial):

Setting the platform to Windows Store
Click file->build Settings ...

Scroll down the platform selector and select Windows Store Apps:

Click the Switch Platform button to make the Windows 8 Platform your standard (you can still export to the other platforms) .

Now, click the Player Settings ... button to view the properties for this platform in this solution.

This screen would let you change a lot of properties based on the platform you want to publish. Clicking the Publishing Settings tab in the bottom would open the Spesific Settings for the selected platform. Click this now:

Set the Tile logo properties like this, using the three textures we added to the publishing folder:

This sets the game tiles for our game (Icons from the Start menu).

We also need to set the splash screens for our game. Set it to splash.png from the Tutorials Assets folder:

Iii. Exporting the Package

To export your game, go the Build Settings (file->build Settings ...) again and click Build:

Save it in a folder of your choice (I created a Windows8 folder in the Unity solution). A Visual Studio solution is now built for the game. It might take a couple of minutes.

A folder where the project is located would be openet and would look something like this:

Iv. Opening the project in Visual Studio to build the store pacakge

To open this, you'll need Visual Studio 2013. If you is a student you might can get a licence from www.dreamspark.com, if not, you can download the Express version for Free here:http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-8

Once This was installed, open the Invad0rs.sln in Visual Studio 2012.

The project is now loaded in Visual Studio 2012:

Now, the build arcitecture to the correct one (probably x86):

Click Play on Local machine (Windows 8) to build the Windows Store App package (. appx) and run the game:

The game would now deploy on your Windows 8 device, and run perfectly. You can also see from the Start menu, the tiles we created are used:

V. Continue the implementation/support of Snapped View

How are we do this depends on "when" selected when exporting the project. There is a drop down list in Unitys export tool:

A) XAML C # Solution

Open the App.xaml.cs file:

The file would look like this (I'll show you the entire code–everything's isn't very interesting here, I'll highlight The important things:

Using System;
Using System.Collections.Generic;
UsingSystem.IO;
UsingSystem.Linq;
Using Windows.applicationmodel;
Using Windows.ApplicationModel.Activation;
Using Windows.foundation;
Using Windows.Foundation.Collections;
UsingWindows.UI.Core;
UsingWindows.UI.Xaml;
UsingWindows.UI.Xaml.Controls;
UsingWindows.UI.Xaml.Controls.Primitives;
UsingWindows.UI.Xaml.Data;
UsingWindows.UI.Xaml.Input;
UsingWindows.UI.Xaml.Media;
UsingWindows.UI.Xaml.Navigation;
Using Unityplayer;
using Windows.UI.ViewManagement;
The Blank application template is documented athttp://go.microsoft.com/fwlink/?LinkId=234227

Namespace Template
{
<summary>
Provides application-specific behavior to supplement the default Application class.
</summary>
Sealed partial class App:application
{
Private Winrtbridge.winrtbridge _bridge;
Private Appcallbacks appcallbacks;
<summary>
Initializes the singleton application object. The first line of authored code
executed, and as such is the logical equivalent of main () or WinMain ().
</summary>
Public App ()
{
This. InitializeComponent ();
Appcallbacks = new Appcallbacks (false);
}

       // <summary>
       //Invoked when the application are launched normally by The end user.  other entry points
       //Would be a used when the application is launched to open a specific file, to display
       //search results, and so Forth.
       //</summary>
        //<param name= "args" >details about the launch request and PROCESS.</PARAM>
   & nbsp;    protected override void OnLaunched (Launchactivatedeventargs args)
         {
            Frame rootframe = Window.Current.Content as Frame;

Setup Scripting Bridge
_bridge = new Winrtbridge.winrtbridge ();
Appcallbacks.setbridge (_bridge);

Appcallbacks.setswapchainbackgroundpanel (Mainpage.getswapchainbackgroundpanel ());

Appcallbacks.setcorewindowevents (Window.Current.CoreWindow);

Appcallbacks.initialized3dxaml ();
}

Window.Current.Activate ();

Window.Current.SizeChanged + = current_sizechanged;
}

void Current_sizechanged (object sender, Windowsizechangedeventargs e)
{
Applicationviewstate myviewstate =Applicationview.value;
if (myviewstate = = applicationviewstate.snapped)
{
AppCallbacks.Instance.InvokeOnAppThread (new Appcallbackitem () = {
Windows8handler.pausegame (TRUE);
}), false);
} else {
AppCallbacks.Instance.InvokeOnAppThread (new Appcallbackitem () = {
Windows8handler.pausegame (FALSE);
}), false);
}
}
}
}

First of all, we add a using statement for the Windows.UI.ViewManagementand then we add a listener to the Sizechang Ed event, this is the event of the app uses to know what to handle a change in Resolution/screen size–what snap view really Is.

Now, the body of this function looks a bit strange.

The "We do" here "to get" the new state our app are in, and then check if the "is the" the snapped state.

What's next is so we use the AppCallbacks.Instance.InvokeOnAppThread to communicate with "our game" on the same thread, Meaning we simply can call Windows8handler.pausegame (true);

If it ' s not snapped view, we unpause the game.

Simple?

b) XAML C + + solution

Not yet written.

c) D3d11 C # Solution

Not yet written.

D) D3d11 C + + solution

Not yet written.

Vi. Setting Some important project properties before we is ready to submit

Now, there are a couple of things we need to does before we can send this to the Windows Store for publishing. Click project->invad0rs Properties ...

On the Applications tab, click Assembly Information:

Set the Language to the Language of the app:

Also, fill out the need, and click OK.

Vii. Creating a publishing account on Windows Store and create your app project in the portal

Creating an account and registering as a publisher are quite easy. Just go tohttp://dev.windows.com, register your account and get it verified (might take a few minutes to a couple of days) .

Creating a project on Windows Store
Go to dev.windows.com, log in with your account and click "DASHBOARD":

Now click the Submit new app (or something similar):

(screenshot is Norwegian and should be the same)

Now, the first thing we want to the reserve an app name so nobody else takes it. Do this now (step 1 on the page) and save:

Binding the app in Visual Studio for the new app name we just created is simple. Go to Visual Studio #, make sure the game project are opened and click Project->associate App with Store ...

Sign in with your developer account. A List of your apps in Store would be displayed. Find the one just reserved for this project:

Click the project name, and click Next.

Then review the It looks right, and click Associate:

Now we is ready to create the App for publishing.

Viii. Building the appx file
Click project->store->create App Packages:

Select Yes, the want to upload the package:

and click Sign In.
Select the app from the list again:

Click Next, note the path where the APP package is generated, and check the different architectures you want the A PP on:

Click Create to generate the package. A few tests'll be run on the packages to ensure you meet a lot of store requirements like memory usage, performance, STA Rtup time and so on. Just Leave it running and let your computer is for the tests. Don ' t disturb it!

Once done, the appx file is created.

Now, go to the Windows Store page where you reserved the name, follow the rest of the steps and upload the appx file. Then submit the app and it'll be sent for testing. This can take a few days.

If your app is accepted, it can be found in the Windows Store. If not, fix the errors they found and resumit (just dont give up!).

and.. Good luck with your sales!

Download:tutorial Part II Assets

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.