Porting unity games to windows - London Unity User Group
-
Upload
lee-stott -
Category
Technology
-
view
568 -
download
5
Transcript of Porting unity games to windows - London Unity User Group
Porting…
Store
Lifecycle
Splash Screen
Settings
Networking
Platform APIs
GPU
Memory
Input
Layout/Screen
Hardware
Live Tiles
Notifications
Sharing
Voice (WP only)
Light-up
Porting recommendations
1. Prepare your game for x-platform
2. Port your logic
3. Port or replace your plugins
4. Platform specific optimizations
& configuration
5. Implement Light-up
6. Optimize performance
Preparing for x-platform
Feature Detection
Dynamic screen size/resolution
Portable Scripts (with platform defines)
Plugins
Compile & run-time differences
Compiler: Mono Run-time: Mono
Compiler: Mono Run-time: .NET for WP
Compiler: .NET Run-time: .NET Core + WinRT
Universal apps (WP 8.1, Win8 & 8.1 )
Windows Phone 8 Unity Editor
.NET CLR (Desktop)
Mono and.NET Core differences…
Mono is a subset of .NET Framework
Mono
.NET Core
Trouble!!
These classes exist in Mono but are not available to Unity in Windows Store and Phone!!
.NET Core is a subset of .NET Framework
What is missing?
Namespace Example classes Workaround
System.Collections Hashtable, ArrayList, List Use WinRTLegacy (from Unity)
System.IO File, StreamReader, TextReader Write using Windows.Storage
System.Xml XmlDocument, XmlElement Use WinRTLegacy for basic coverage
System.Reflection Write using equivalent WinRT APIs
System.Security.Cryptography SHA1, TripleDES Use WinRTLegacy for basic coverage
System.Net Socket, NetworkStream Use WinRT networking APIs
System.Threading Thread WinRT is async, use Task, use coroutines
System.Runtime.Serialisation BinaryWriter No direct binary support. Use alternate methods
Conditional Compilation on Windows/Universal
Use .NET Core (default)C# compiled using MS Compiler
Can call Windows Runtime APIs from inline scripts
C# types are not visible to JS classes
.NET Core partially C# scripts in ( Plugins || Standard Assets) use Mono Compiler, can’t
reference Windows Run-time
C# types compiled w/ Mono are visible to JS scripts
None Uses Mono compiler for everything, no inline calls to WinRT types
Windows Store
Keyboard
Mouse
Touch
Accelerometer/Gyro
Camera
Microphone
Controller
Windows Phone
Touch
Accelerometer or Gyro
Camera
Microphone
Back Button
Input
Capabilities (Windows Phone)
Developers must declare
hardware or software capabilities
in the app’s manifest
Users get presented the required
capabilities upon install
Capabilities (Windows)
Developers must declare
hardware or software
capabilities in the app’s
manifest
Users get presented the
required capabilities upon
install
Back button ( Windows Phone )
Windows Phone: App pops the back stack or dismisses modal UI if back button is pressed
App exits when back button is pressed from ‘home’ page and no modal
UI is visible
Unity Handles back button (natively) and maps it to KeyCode.Escape
Exits the app if back button pressed and Application.Quit is called ( )
Back button
//Unity does this for you automatically
<phone:PhoneApplicationPageBackKeyPress="PhoneApplicationPage_BackKeyPress" >
private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e)
{
e.Cancel = UnityApp.BackButtonPressed();
}
//IN your unity code, handle back button, you should quit, go back or dismiss modal UI
void Update {
if (Input.GetKeyDown(KeyCode.Escape)){
Application.Quit();
} }
Keyboard (Phone & Windows, Unity 4.5+ )
Seamless keyboard support via GUI
Programmatic access via TouchScreenKeyboard classOn Windows, set keyboard.area is not supported
Setting keyboard.active after instantiate is not required anymore
Memory (Windows Phone)
Memory Limits
http://msdn.microsoft.com/en-us/library/windows/apps/jj681682(v=vs.105).aspx
App type 512 MB 1-GB phones 2-GB phones
Windows Phone 8.0 180 MB 380 MB 780 MB
Silverlight 8.1 and Windows Runtime 8.1
185 MB 390 MB 825 MB
App type Platform
ID_FUNCCAP_EXTEND_MEM Gets you the 180 MB and 380MB WP8
ID_REQ_MEMORY_300 Opts out of lower memory devices WP8
minDeviceMemory Appx similar for ID_REQ_MEMORY WP81, Appx
Manifest settings
Memory Tips (Windows Phone)
Test on low-end devices
Use the Unity profiler
Compress textures to DXT1 or DXT5
Reduce Audio Memory Usage
‘Stream from disc’ instead of ‘Compressed in memory’
Memory, useful APIs (Windows Phone)
DeviceStatus.DeviceTotalMemory
DeviceStatus.ApplicationCurrentMemoryUsage
DeviceStatus.ApplicationPeakMemoryUsage
Asset bundles
Can’t be explicitly downloaded
Useful to support multiple resolutions
Useful to chunk features (e.g. tutorial)
Audio ( Phone)
If you hear “crackles” on debug builds, try master
Test on devices, emulator will not be representative
To maximize memory, stream from disk
Look at media codecs for Windows Phone http://msdn.microsoft.com/en-
us/library/windows/apps/ff462087(v=vs.105).aspx
Handling Screen Size Changes
UnityEngine.WSA.Application.windowSizeChanged += WindowSizeChanged;
public static void WindowSizeChanged(int width, int height)
{
if(width <= 500) {
GameController.SP.paused();
}
else {
GameController.SP.unpaused();
}
}
Summary
Different run-times Editor is Mono
Device is .NET
A fairly typical hardware port Pay attention to
Memory on Windows Phone 8
Back button
Input on Windows
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.