windowsgamessamples / UnityPorting

Porting Unity Games to Windows
40 stars 32 forks source link

Unity Porting Code Samples

Read the Whitepapers

This repo has been created as reference code samples for a set of whitepapers produced to help developers in porting their Unity games to Windows 8.1 and Windows Phone 8.

It is recommended that you read these whitepapers before delving into the code.

The prerequisites for working with these samples are in either of the Getting Started documents above.

What's in the repo?

Small demonstrations and code snippets for most of the approaches outlined in the papers.

This repo contains the following folders:

There are currently the following tasks in the game for both Windows 8.1 and Windows Phone 8

For Windows 8.1, there are a couple of extra snippets

Building the solution

The first time you build, you need to follow specific order:

  1. Build to Windows Store and then Windows Phone in Unity 4.3.1 (over top of projects in the Windows solution folder)
  2. Build the Windows Solution (which will automatically add Nuget dependencies)
  3. Run the Windows Store or Windows Phone App!

See below for tips on each step:

Building the Windows Store Player from Unity

Note: If you make changes to Unity scripts and game, you can just keep building to PlatformerWindowsStore project and it won't override your Visual studio project. If you add new plugins or change the player preferences, you will need to merge these manually.

Building Windows Phone App from Unity

Note: If you make changes to Unity scripts and game, you can just keep building to PlatformerWindowsPhone project and it won't override your Visual studio project. If you add new plugins or change the player preferences, you will need to merge these manually.

Building and running for Windows Store

Building and running for Windows Phone

Updating the Sample Plugin

The plugin binary outputs are included in the Unity project automatically, but you can update and easily have Unity get the updated plugins.

To build the plugin, open the \UnityPorting\PlatformerPlugin\PlatformerPlugin.sln with Visual Studio 2013 and set the build configuration for "Release" and "Any CPU", there is a post build event that will automatically copy the resulting MyPlugin.dll (and any adjacent dlls in the target directory) to the correct locations in the Unity project automatically as follows:

Note: If you make changes to the plugins later, every time you update the plugin, you should rebuild in Unity and Visual Studio. Make sure in Visual Studio when rebuilding the plugins, to set the build to 'Release' and 'Any CPU'.

Upcoming features

We are just getting started. Currently, it is a sample and lots of useful snippets you can copy and paste into your projects.
We need to:

Known issues

Facebook plugin issue on Windows Phone 8 - The web page that appears after selecting a friend to invite has intermittent issues, sometimes the cancel/send invite buttons don't appear. The buttons when they do appear never work though. This is a WP8 specific issue.