Friday, August 12, 2016

Unreal Engine 4 porting a game to XboxOne using UWP

This tutorial are the steps it takes to port a UE4 game to a retail XboxOne in Developer Mode. Note: Currently this process only works for 2D Games only.  You can port 3D games to the XboxOne from UE4 as a Universal Windows App, but those games will crash at the splash screen due to some D3D incompatibility issues, hopefully future versions will include the ability to port 3D games.

Requirements:
1. This tutorial requires that you are running Windows 10, and have Visual Studio 2015 installed with C++ Language, Windows 10 SDK, and Universal Windows Platform.  You can download all of these from within the Visual Studio 2015 installer.  Make sure you have all of these set up and working before moving on.

2. You will also want to download the Epic Games Launcher for some later steps in this tutorial.

Setup:
1. First, download the latest build of Microsoft_UWP_Unreal https://github.com/MICROSOFT-XBOX-ATG/MICROSOFT_UWP_UNREAL/tree/bb1671cb37768dcc089e38fed07fbc814a6679f1 Note: before being able to access this build, you must be a registered UE4 user, and you must link your UE4 account to GitHub, the directions for that can be found here https://www.unrealengine.com/ue4-on-github

2. Once you download the Microsoft UWP Unreal build, extract it onto your local HDD.

3. In the folder, you will need to set up your project with some dependencies.  To do so, run the Setup.bat file which is located in the root of your extracted Microsoft UWP Unreal folder.  This setup file may take some time to download an install dependences, and mostly depends on your download speed.

4. Once you are done with Setup.bat, run GenerateProjectFiles.bat from the same root folder, which will generate Visual Studio project files.

5. At this point, you should see a UE4 Visual Studio Solution file, which you will need to run and it will load the project that you just generated in Visual Studio.

6. Next, run the project (or press F5).  Visual Studio will first go through the build process, which can take some time depending on your machine specifications, expect this to take anywhere from 30 minutes to 2 hours.  After the build process is done, this means that you have compiled the UWP customized version of UE4, and will automatically run the editor. 

7. Now that the editor is up and running you should see the typical GUI that allows you to navigate New Project, choose C++, and 2D Side Scroller.  As mentioned above other projects that have 3D graphics do not currently run on XboxOne, but there have been reports of 3D games porting from UE4 to Windows Phone and HoloLens.  Once you are finished creating your project close it out, close out the editor, and close out Visual Studio.

8. Locate the Epic Games Launcher, and run it as administrator. In your Library under My Projects, you should see the project you just made using your custom built UWP UE4.  Run it.  We are running this project as administrator because Windows will block access to Unreal Build Tools when publishing the project, so we need to run the project in administrator mode.

9. Before we can continue, we need to create the proper Certificates for the Universal Windows App you are about to create. To do so, run Command Prompt as Administrator.  Navigate to C:\Program Files (x86)\Windows Kits\10\bin\x86
You need  be using x86 because XboxOne architecture is x86.  First create a pvk certification file by typing this into the command prompt:
makecert MyCert.cer -r -n "CN=My Company" -$ individual -sv MyCert.pvk -pe -cy end

Note: MyCert will be the name of the certification file, you can name this anything you want.  CN=My Company will be your company name, which you will need to reference in your UE4 Project Properties.  This can be anything you want as well, but you MUST prefix everything you do with CN=, Universal Windows Platform has made it standard that all company names are prefixed with CN= and will error out during the publishing process if you do not name it this way.

10. Next in your command prompt, convert the pvk certification into a pfx by typing this:
pvk2pfx -pvk MyCert.pvk -spc MyCert.cer -pfx MyCert.pfx

11. In your C:\Program Files (x86)\Windows Kits\10\bin\x86 directory, copy the 3 files you just created (the .cer, .pvk, and .pfx files) and paste them into the root of the Unreal 2D Side Scrolling project you created in step 7.

12. Go back to the project you had opened in step 8. and we can now set up our project for UWP deployment.

13. Navigate to Edit>Project Settings.  Under Project>Description you can keep the defaults for everything but add your company name which you specified in step 9 here, for me my company name was CN=My Company.  Place this company name in Company Name and Company Distinguished Name.  Also fill out Description and Project Display Title.

14. Under Platform>UWP Browse for your .cer file under Signing Certificate.  Also add images for your logos and splash screens that are of the image type of .png.  Also, change the Background Colors to anything you want (there have been crash reports when users have kept the background colors as the default black).

15. A.W.E.S.O.M.E.  This step is all about congratulating you for getting this far!  We are now finished with the setup.  Get rehydrated and let us move on to publishing and deployment.

Publishing:
1. Navigate to File>Package Project>Universal Windows Platform>UWP (x86 32-bit)
Note: As noted above, XboxOne is built with x86 architecture, not x64, so you must package this for x86.

2. You will then be prompted as to which directory you want your UWP game to be placed, then the cooking/packaging/publishing process will start.  This process usually takes a couple hours depending on the specs of your machine.  Go out to the movies, have a nice 6-course dinner, or play about 10 matches in Overwatch and come back to see your build as a success.
Note: If your build failed, it means that one of the many previous steps was done incorrectly.  Be sure to read the log and see where the errors/warnings were which will hopefully give you a clue as to where you messed up.

3. Mazel tov! This calls for another celebration!  You have now finished the hardest part of the entire process.  We are now read to deploy to XboxOne (or any other Windows 10 device like Windows Phone or HoloLens).

XboxOne Deployment:
1. Put your XboxOne in Developer Mode (don't worry, you can back your console out of Developer Mode at any time).  Use the directions here to activate Developer Mode https://msdn.microsoft.com/en-us/windows/uwp/xbox-apps/devkit-activation

2. In Dev Home, under Remote Management open Manage Windows Device Portal. This will allow you to deploy applications remotely to your XboxOne via your home network and manage your XBoxOne While it is in dev mode. You will be prompted with a screen asking you to set up a Username and Password, you can set this up however you want, but make sure you remember the Username and Password because you will need it when connecting to the XboxOne remotely...

3.Once your Windows Device Portal is set up, go back to the PC where you have built your UE4 Game and open up an internet browser, you can access your portal by using the following URL: https://xboxone:11443

4. Make sure to accept the certificates for this URL and you Remote Management to your XboxOne should appear in your browser.

5.  To deploy to XboxOne under Apps Manager>Install App, click the Browse button in App Package to browse your computer for the folder where you packaged your UWP game to and choose your .appx file.  Also under Certificate, locate your certification file that you created and copied over into your UE4 project directory.  When you are done, you can press the GO  button at the bottom of the screen which will send your files to your XboxOne via your network connection, and install the game on your XboxOne. 

6.  You should now see your game under Games & Apps on your XboxOne, and from here you can run your game on the XboxOne.


There you have it, we have published your UE4 game as a Universal Windows App and deployed it to your XboxOne via Developer Mode!

2 comments:

  1. There were no Visual Studio Solution files created after I ran GenerateProjectFiles.bat. I'm very confused...

    ReplyDelete
  2. Builds are definitely not x86, but x64. I was very confused and thought this is why my project wasn't building, then spent 2 hours compiling a x86 build that the Xbox refused to install lol. Thanks for the tutorial, though. I'd never be able to figure out how to sign the certificates by myself. However, mine aren't working. It says that the XML App Manifest is wrong. I went and fixed it manually and it gave out another error and now the game doesn't build. Mystery.

    ReplyDelete