SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Porting Your Unity3D
Game to Windows 8
Store
About Me
• Co-Founder of 282Productions
• Working in the Israeli game development industry for 2 years
• Released several Unity3D powered games
• Currently working on several Unity3D ports to Windows 8
Goals
• Create a Windows 8 App porting “check-list”
• Highlight problems and pitfalls encountered porting to Win8,
and present practical solutions
• Give hands on examples of new Win8 features integration
Getting Started
Getting Started
• To get started you’ll need:
• A computer running Windows 8
• Visual Studio 2012
• Windows Developer Certificate on that computer – you’ll be
prompted to obtain one automatically when first running VS
• Unity3D 4.x with the Windows Store Apps exporter
Hello, Unity4!
• Windows Store Apps exporter is available from Unity4,
which means we might have to upgrade
• Unity4 introduced a new GameObject active state behavior
• In short, SetActive now affect all of an object’s ancestors
• This has a potential of breaking apps that make use of
GameObjects’ active state in certain situations
Deprecated Types in NET4.5
• By default, when targeting Windows Store Apps, Unity
builds the CSharp assembly targeting .NET4.5
• .NET4.5 removed some obsolete types such as ArrayList
and Hashtable
• These types existed historically, they were introduced in
.NET1.1 and became obsolete with the addition of generics
in .NET2.0
• For some reason, ArrayList and Hashtable are still
somewhat commonly used.
Handling Deprecated Types
• Do NOT use ArrayList and Hashtable, use List<T> and
Dictionary<Tkey,Tval> instead
• If these types are used in a third party addon, find a
replacement solution
• If that’s not an option, you can build your CSharp assembly
like before, by setting Project->Build Settings->Player
Settings->Compilation Override to NONE. This will not allow
you to access any of the new features in .NET4.5 though.
New Compiler Directives
• With Unity4, two new compiler directives were added.
#if UNITY_METRO
This will compile, whenever the
active build target is Windows Store
Apps.
Usage:
#if UNITY_METRO
m_versionString += “w8”
#endif
#if NETFX_CORE
This will compile only when building
an app targeting Windows Store
(not in editor more(.
Usage:
#if NETFX_CORE
using Windows.UI.XAML;
#endif
Managed Metro Plugins
• One major change in the Windows Store requirements is
that no WIN32 API calls are made from your app
• In some cases, this would require us to modify or replace
linked libraries
• Unmanaged libraries are handled as before
• Before, managed libraries could be present anywhere within
the project. They were parsed and added to the reference list
as soon as they were added to the project
Managed Metro Plugins
• Managed assemblies built targeting .NET4.5 can’t be placed
anywhere in the project. Unity will still try to resolve links
against Mono, which will obviously fail, and you won’t be
able to build your project.
• Managed .NET4.5 assemblies must be placed under
/Assets/Plugins/Metro
• This, however, does not solve everything. Currently,
assemblies under Plugins/Metro won’t be added to the
project reference list
Managed Metro Plugins
• To solve this:
• Create a mock assembly with matching method signatures
but no implementation
• Target .NET3.5 and build it
• Add it to your project under /Assets/Plugins
• This will add the assembly to the project reference list, but
when building for Store Apps, it will get substituted by the
version under /Assets/Plugins/Metro
Managed Metro Plugins
• Another quick word about assemblies in Win8 Store Apps:
• Make sure you do not have any assemblies built in debug
mode when trying to deploy your application
• Apps referencing debug assemblies will not pass the
automated windows store certification
Ready to Export
• Unity will export our project as a Visual Studio project, which
then needs to be built and deployed through VS
• Our target VS project has two main flavors: D3D and XAML
• D3D Projects create single view application projects with a
D3D context used for rendering Unity’s display
• XAML Projects use the same D3D view, but with the addition
of a XAML UI layer on top
• According to Unity, D3D projects give better performance, as
a tradeoff for the missing XAML layer
Understanding Metro Apps
Metro Apps Threading Model
• A metro app’s main thread is the UI thread
• Guidelines require us to execute long running tasks in
separate threads
• Some operations, mainly UI related, can only be executed
from the UI thread
• By default, Unity will run in a separate thread
• Most likely 80% of all integration problems between unity
and windows are thread related.
Unity <-> Windows Interop
• Unity is NOT thread safe
• Manipulating any object inheriting from UnityEngine.Object
outside of the engine execution thread will either raise an
exception or cause access violation
• We’ve just mentioned windows UI tasks can only be
executed from the UI thread, and Unity runs in a separate
thread. How do we get them to communicate?
• Using AppCallbacks!
AppCallbacks
• AppCallbacks is a singleton object used to bridge between
the Unity Player and the Windows Runtime
• On export, AppCallbacks is automatically defined in our
App.cs source file
• public AppCallbacks(bool appRunsOnUIThread);
• By default, AppCallbacks will be initialized with
appRunsOnUIThread = false
• Don’t change that, understanding the threading model
instead of hacking around it
Making That Useful
• AppCallbacks.Instance.IntegrateIntoAppThread( item, sync)
• Item = AppCallbacksItem, void task() delegate
Integrate New Features
Snapped View
• Windows Store Apps can be resized to one of four sizes – FullScreen
Landscape, FullScreen Portrait, Filled or Snapped
Reacting To Resolution Changes
• Add an event to our game that will be used to notify game elements the
resolution has changed. From here the event will propagate into our
system
• Next, attach the desired behavior to the event handlers: pause the game,
display a message, etc…
Reacting To Resolution Changes
• In your VS solution, add an event handler to
Window.Current.SizeChanged
• And you’re done!
Live Tiles
• Let’s try something more daring! Let’s update the app live tile from within
our CSharp assembly!
Let’s Recap
The Check List
1. Our project functions properly in Unity4
2. We don’t use any .NET4.5 unsupported types
3. If using plugins, we have a suitable version for Windows 8: no calls to
win32 APIs, and not built in debug mode
4. We handle resolution changes, and our app functions properly in all
resolution modes
5. Support both mouse/keyboard and touch inputs
6. If our app connects to the internet, it has a privacy policy
7. Additionally, we’ve integrated new Windows 8 functionality, such as Live
Tiles, Share Contracts, Store IAPs
When Things Go Wrong
Debugging & Testing
• Feature Support:
• We can debug the code in our CSharp assembly from VS
• We can either deploy and debug locally, or on a remote
machine
• We can create test packages and distribute for testing
Debbuging CSharp Assembly
• To debug our CSharp assembly in Visual Studio, we need to
add Unity’s CS project to our VS solution
• In VS, right click the solution in the solution explorer, select
Add->Existing Project, browse to the Unity project root folder
and add the Assembly-CSharp.csproj
• This will add our CSharp assembly to the solution view, here
we can browse our source files and add breakpoints
Remote Debugging
• To debug remotely, we will need to install the VS2012 Remote
Debugging Tools on the target machine
• The installation can be found on the VS2012 install DVD, or
can be downloaded from Microsoft’s website
• Once installed, the target machine and the host need to be
connected to the same network, preferably through wired
connection
• To start debugging, select the “Play” button dropdown, and
switch to remote machine. This will prompt the remote debug
configuration dialog
Deploying Test Builds
• To distribute test builds, we will need to pack the application
• From the toolbar select Project->Store->Create App
Packages
• When asked if you want to package for the Windows Store,
select NO
• Continue through the remaining dialogs, until you’ve got an
app package ready.
• Distribute your app package for testing
Installing Test Builds
• The test package output folder contains the package, the
signing certificate file, and an installation PowerShell Script
• To install it on a test machine, right click the PowerShell script
file Add-AppDevPackage.ps1, and select “Run With
PowerShell”
• This script will automatically install the package
• Keep in mind that to install test packages, you must have a
valid developer license on the target machine
Questions?
Thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

Rit 8.5.0 training cloud instructions
Rit 8.5.0 training cloud instructionsRit 8.5.0 training cloud instructions
Rit 8.5.0 training cloud instructions
Darrel Rader
 
03 Beginning Android Application Development
03 Beginning Android Application Development03 Beginning Android Application Development
03 Beginning Android Application Development
Arief Gunawan
 
Appium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeAppium: Mobile Automation Made Awesome
Appium: Mobile Automation Made Awesome
Netcetera
 
Installing And Configuring Java Me Tools
Installing And Configuring Java Me ToolsInstalling And Configuring Java Me Tools
Installing And Configuring Java Me Tools
Jussi Pohjolainen
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
Deepa Rani
 
Selenium_WebDriver_Java_TestNG
Selenium_WebDriver_Java_TestNGSelenium_WebDriver_Java_TestNG
Selenium_WebDriver_Java_TestNG
Basul Asahab
 
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Ryan Baxter
 
7.imaging on windows phone
7.imaging on windows phone7.imaging on windows phone
7.imaging on windows phone
Nguyên Phạm
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
Nicholas Jansma
 

Was ist angesagt? (20)

Rit 8.5.0 training cloud instructions
Rit 8.5.0 training cloud instructionsRit 8.5.0 training cloud instructions
Rit 8.5.0 training cloud instructions
 
03 Beginning Android Application Development
03 Beginning Android Application Development03 Beginning Android Application Development
03 Beginning Android Application Development
 
Getting Enter in Android development
Getting Enter in Android developmentGetting Enter in Android development
Getting Enter in Android development
 
Meteor
MeteorMeteor
Meteor
 
Homestead demo
Homestead demoHomestead demo
Homestead demo
 
AndEngine
AndEngineAndEngine
AndEngine
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
 
Appium: Mobile Automation Made Awesome
Appium: Mobile Automation Made AwesomeAppium: Mobile Automation Made Awesome
Appium: Mobile Automation Made Awesome
 
Android Overview
Android OverviewAndroid Overview
Android Overview
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Supplement J Eclipse
Supplement J EclipseSupplement J Eclipse
Supplement J Eclipse
 
Installing And Configuring Java Me Tools
Installing And Configuring Java Me ToolsInstalling And Configuring Java Me Tools
Installing And Configuring Java Me Tools
 
Android development module
Android development moduleAndroid development module
Android development module
 
Android the first app - hello world - copy
Android   the first app - hello world - copyAndroid   the first app - hello world - copy
Android the first app - hello world - copy
 
Selenium_WebDriver_Java_TestNG
Selenium_WebDriver_Java_TestNGSelenium_WebDriver_Java_TestNG
Selenium_WebDriver_Java_TestNG
 
Getting Started with Coded UI Testing: Building Your First Automated Test
Getting Started with Coded UI Testing: Building Your First Automated TestGetting Started with Coded UI Testing: Building Your First Automated Test
Getting Started with Coded UI Testing: Building Your First Automated Test
 
Android Fundamentals
Android FundamentalsAndroid Fundamentals
Android Fundamentals
 
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
 
7.imaging on windows phone
7.imaging on windows phone7.imaging on windows phone
7.imaging on windows phone
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 

Andere mochten auch

Developing Games For VR - Lessons Learned
Developing Games For VR - Lessons LearnedDeveloping Games For VR - Lessons Learned
Developing Games For VR - Lessons Learned
Martin Climatiano
 
Barcelona FC coaching clinic
Barcelona FC coaching clinicBarcelona FC coaching clinic
Barcelona FC coaching clinic
Ricardo Luiz Pace
 
Jacqueline Novogratz by Anne Decourcy Conlin
Jacqueline Novogratz by Anne Decourcy ConlinJacqueline Novogratz by Anne Decourcy Conlin
Jacqueline Novogratz by Anne Decourcy Conlin
Stew Friedman
 
Bill gates leadership & personality traits
Bill gates leadership & personality traitsBill gates leadership & personality traits
Bill gates leadership & personality traits
Akhil Pillai
 

Andere mochten auch (20)

Developing Games For VR - Lessons Learned
Developing Games For VR - Lessons LearnedDeveloping Games For VR - Lessons Learned
Developing Games For VR - Lessons Learned
 
Maya To Unity3D
Maya To Unity3DMaya To Unity3D
Maya To Unity3D
 
Barcelona FC coaching clinic
Barcelona FC coaching clinicBarcelona FC coaching clinic
Barcelona FC coaching clinic
 
Role of Grameen Bank In Poverty alleviation
Role of Grameen Bank In Poverty alleviationRole of Grameen Bank In Poverty alleviation
Role of Grameen Bank In Poverty alleviation
 
Apple inc
Apple incApple inc
Apple inc
 
Apple inc
Apple incApple inc
Apple inc
 
LESS vs. SASS - CSS Precompiler Showdown
LESS vs. SASS - CSS Precompiler ShowdownLESS vs. SASS - CSS Precompiler Showdown
LESS vs. SASS - CSS Precompiler Showdown
 
Jacqueline Novogratz by Anne Decourcy Conlin
Jacqueline Novogratz by Anne Decourcy ConlinJacqueline Novogratz by Anne Decourcy Conlin
Jacqueline Novogratz by Anne Decourcy Conlin
 
Apple Inc.
Apple Inc.Apple Inc.
Apple Inc.
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
 
Mckinsey and Company Presentation
Mckinsey and Company PresentationMckinsey and Company Presentation
Mckinsey and Company Presentation
 
Bill gates leadership & personality traits
Bill gates leadership & personality traitsBill gates leadership & personality traits
Bill gates leadership & personality traits
 
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBoosterDigital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
Digital Data Tips Tuesday #1 - Tag Management: Simo Ahava - NetBooster
 
Growth Hacking
Growth Hacking Growth Hacking
Growth Hacking
 
Manchester city
Manchester cityManchester city
Manchester city
 
Smart Cities – how to master the world's biggest growth challenge
Smart Cities – how to master the world's biggest growth challengeSmart Cities – how to master the world's biggest growth challenge
Smart Cities – how to master the world's biggest growth challenge
 
Google's Avinash Kaushik on Web Analytics
Google's Avinash Kaushik on Web AnalyticsGoogle's Avinash Kaushik on Web Analytics
Google's Avinash Kaushik on Web Analytics
 
Workshop
WorkshopWorkshop
Workshop
 
Datomic
DatomicDatomic
Datomic
 
Jim rohn
Jim  rohnJim  rohn
Jim rohn
 

Ähnlich wie Migrating Unity3D projects to Windows 8

Develop android application with mono for android
Develop android application with mono for androidDevelop android application with mono for android
Develop android application with mono for android
Nicko Satria Consulting
 

Ähnlich wie Migrating Unity3D projects to Windows 8 (20)

W1.pptx
W1.pptxW1.pptx
W1.pptx
 
Develop android application with mono for android
Develop android application with mono for androidDevelop android application with mono for android
Develop android application with mono for android
 
Ios - Intorduction to view controller
Ios - Intorduction to view controllerIos - Intorduction to view controller
Ios - Intorduction to view controller
 
HoloLens Unity Build Pipelines on Azure DevOps
HoloLens Unity Build Pipelines on Azure DevOpsHoloLens Unity Build Pipelines on Azure DevOps
HoloLens Unity Build Pipelines on Azure DevOps
 
Real World Windows 8 Apps in JavaScript
Real World Windows 8 Apps in JavaScriptReal World Windows 8 Apps in JavaScript
Real World Windows 8 Apps in JavaScript
 
Android wear notes
Android wear notesAndroid wear notes
Android wear notes
 
Build Your First Android App Session #1
Build Your First Android App Session #1Build Your First Android App Session #1
Build Your First Android App Session #1
 
Windows10 tools-tools-tools
Windows10 tools-tools-toolsWindows10 tools-tools-tools
Windows10 tools-tools-tools
 
Windows 10 - tools-tools-tools
Windows 10 - tools-tools-toolsWindows 10 - tools-tools-tools
Windows 10 - tools-tools-tools
 
Netbeans gui tutorial
Netbeans gui tutorialNetbeans gui tutorial
Netbeans gui tutorial
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Developing for Android-Types of Android Application
Developing for Android-Types of Android ApplicationDeveloping for Android-Types of Android Application
Developing for Android-Types of Android Application
 
Bring and distribute your dekstop applications on the Universal Windows Platf...
Bring and distribute your dekstop applications on the Universal Windows Platf...Bring and distribute your dekstop applications on the Universal Windows Platf...
Bring and distribute your dekstop applications on the Universal Windows Platf...
 
Introduction_to_android_and_android_studio
Introduction_to_android_and_android_studioIntroduction_to_android_and_android_studio
Introduction_to_android_and_android_studio
 
Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015
 
Getting started windows store unity
Getting started windows store unityGetting started windows store unity
Getting started windows store unity
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
 
Presentation[1]
Presentation[1]Presentation[1]
Presentation[1]
 
Android class provider in mumbai
Android class provider in mumbaiAndroid class provider in mumbai
Android class provider in mumbai
 
Android Wearable App Development - 1
Android Wearable App Development - 1Android Wearable App Development - 1
Android Wearable App Development - 1
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Migrating Unity3D projects to Windows 8

  • 1. Porting Your Unity3D Game to Windows 8 Store
  • 2. About Me • Co-Founder of 282Productions • Working in the Israeli game development industry for 2 years • Released several Unity3D powered games • Currently working on several Unity3D ports to Windows 8
  • 3. Goals • Create a Windows 8 App porting “check-list” • Highlight problems and pitfalls encountered porting to Win8, and present practical solutions • Give hands on examples of new Win8 features integration
  • 5. Getting Started • To get started you’ll need: • A computer running Windows 8 • Visual Studio 2012 • Windows Developer Certificate on that computer – you’ll be prompted to obtain one automatically when first running VS • Unity3D 4.x with the Windows Store Apps exporter
  • 6. Hello, Unity4! • Windows Store Apps exporter is available from Unity4, which means we might have to upgrade • Unity4 introduced a new GameObject active state behavior • In short, SetActive now affect all of an object’s ancestors • This has a potential of breaking apps that make use of GameObjects’ active state in certain situations
  • 7. Deprecated Types in NET4.5 • By default, when targeting Windows Store Apps, Unity builds the CSharp assembly targeting .NET4.5 • .NET4.5 removed some obsolete types such as ArrayList and Hashtable • These types existed historically, they were introduced in .NET1.1 and became obsolete with the addition of generics in .NET2.0 • For some reason, ArrayList and Hashtable are still somewhat commonly used.
  • 8. Handling Deprecated Types • Do NOT use ArrayList and Hashtable, use List<T> and Dictionary<Tkey,Tval> instead • If these types are used in a third party addon, find a replacement solution • If that’s not an option, you can build your CSharp assembly like before, by setting Project->Build Settings->Player Settings->Compilation Override to NONE. This will not allow you to access any of the new features in .NET4.5 though.
  • 9. New Compiler Directives • With Unity4, two new compiler directives were added. #if UNITY_METRO This will compile, whenever the active build target is Windows Store Apps. Usage: #if UNITY_METRO m_versionString += “w8” #endif #if NETFX_CORE This will compile only when building an app targeting Windows Store (not in editor more(. Usage: #if NETFX_CORE using Windows.UI.XAML; #endif
  • 10. Managed Metro Plugins • One major change in the Windows Store requirements is that no WIN32 API calls are made from your app • In some cases, this would require us to modify or replace linked libraries • Unmanaged libraries are handled as before • Before, managed libraries could be present anywhere within the project. They were parsed and added to the reference list as soon as they were added to the project
  • 11. Managed Metro Plugins • Managed assemblies built targeting .NET4.5 can’t be placed anywhere in the project. Unity will still try to resolve links against Mono, which will obviously fail, and you won’t be able to build your project. • Managed .NET4.5 assemblies must be placed under /Assets/Plugins/Metro • This, however, does not solve everything. Currently, assemblies under Plugins/Metro won’t be added to the project reference list
  • 12. Managed Metro Plugins • To solve this: • Create a mock assembly with matching method signatures but no implementation • Target .NET3.5 and build it • Add it to your project under /Assets/Plugins • This will add the assembly to the project reference list, but when building for Store Apps, it will get substituted by the version under /Assets/Plugins/Metro
  • 13. Managed Metro Plugins • Another quick word about assemblies in Win8 Store Apps: • Make sure you do not have any assemblies built in debug mode when trying to deploy your application • Apps referencing debug assemblies will not pass the automated windows store certification
  • 14. Ready to Export • Unity will export our project as a Visual Studio project, which then needs to be built and deployed through VS • Our target VS project has two main flavors: D3D and XAML • D3D Projects create single view application projects with a D3D context used for rendering Unity’s display • XAML Projects use the same D3D view, but with the addition of a XAML UI layer on top • According to Unity, D3D projects give better performance, as a tradeoff for the missing XAML layer
  • 16. Metro Apps Threading Model • A metro app’s main thread is the UI thread • Guidelines require us to execute long running tasks in separate threads • Some operations, mainly UI related, can only be executed from the UI thread • By default, Unity will run in a separate thread • Most likely 80% of all integration problems between unity and windows are thread related.
  • 17. Unity <-> Windows Interop • Unity is NOT thread safe • Manipulating any object inheriting from UnityEngine.Object outside of the engine execution thread will either raise an exception or cause access violation • We’ve just mentioned windows UI tasks can only be executed from the UI thread, and Unity runs in a separate thread. How do we get them to communicate? • Using AppCallbacks!
  • 18. AppCallbacks • AppCallbacks is a singleton object used to bridge between the Unity Player and the Windows Runtime • On export, AppCallbacks is automatically defined in our App.cs source file • public AppCallbacks(bool appRunsOnUIThread); • By default, AppCallbacks will be initialized with appRunsOnUIThread = false • Don’t change that, understanding the threading model instead of hacking around it
  • 19. Making That Useful • AppCallbacks.Instance.IntegrateIntoAppThread( item, sync) • Item = AppCallbacksItem, void task() delegate
  • 21. Snapped View • Windows Store Apps can be resized to one of four sizes – FullScreen Landscape, FullScreen Portrait, Filled or Snapped
  • 22. Reacting To Resolution Changes • Add an event to our game that will be used to notify game elements the resolution has changed. From here the event will propagate into our system • Next, attach the desired behavior to the event handlers: pause the game, display a message, etc…
  • 23. Reacting To Resolution Changes • In your VS solution, add an event handler to Window.Current.SizeChanged • And you’re done!
  • 24. Live Tiles • Let’s try something more daring! Let’s update the app live tile from within our CSharp assembly!
  • 26. The Check List 1. Our project functions properly in Unity4 2. We don’t use any .NET4.5 unsupported types 3. If using plugins, we have a suitable version for Windows 8: no calls to win32 APIs, and not built in debug mode 4. We handle resolution changes, and our app functions properly in all resolution modes 5. Support both mouse/keyboard and touch inputs 6. If our app connects to the internet, it has a privacy policy 7. Additionally, we’ve integrated new Windows 8 functionality, such as Live Tiles, Share Contracts, Store IAPs
  • 27. When Things Go Wrong
  • 28. Debugging & Testing • Feature Support: • We can debug the code in our CSharp assembly from VS • We can either deploy and debug locally, or on a remote machine • We can create test packages and distribute for testing
  • 29. Debbuging CSharp Assembly • To debug our CSharp assembly in Visual Studio, we need to add Unity’s CS project to our VS solution • In VS, right click the solution in the solution explorer, select Add->Existing Project, browse to the Unity project root folder and add the Assembly-CSharp.csproj • This will add our CSharp assembly to the solution view, here we can browse our source files and add breakpoints
  • 30. Remote Debugging • To debug remotely, we will need to install the VS2012 Remote Debugging Tools on the target machine • The installation can be found on the VS2012 install DVD, or can be downloaded from Microsoft’s website • Once installed, the target machine and the host need to be connected to the same network, preferably through wired connection • To start debugging, select the “Play” button dropdown, and switch to remote machine. This will prompt the remote debug configuration dialog
  • 31. Deploying Test Builds • To distribute test builds, we will need to pack the application • From the toolbar select Project->Store->Create App Packages • When asked if you want to package for the Windows Store, select NO • Continue through the remaining dialogs, until you’ve got an app package ready. • Distribute your app package for testing
  • 32. Installing Test Builds • The test package output folder contains the package, the signing certificate file, and an installation PowerShell Script • To install it on a test machine, right click the PowerShell script file Add-AppDevPackage.ps1, and select “Run With PowerShell” • This script will automatically install the package • Keep in mind that to install test packages, you must have a valid developer license on the target machine