- Home /
Determining if you're on a build for Windows Store/Metro
Hello,
I can't use conditional compilation in one of my projects (it's an external assembly), so I can't use #if UNITY_METRO to determine if I'm on Windows Store/Metro, and I have to rely on Application.Platform. Problem is, the returned enumerator (RuntimePlatform) doesn't have a Metro value, only a WP8Player one (which is for Windows 8 Phone). Anyone knows how else I can do it?
Thanks
Answer by CanisLupus · Jun 23, 2014 at 10:16 PM
(in Unity 5)
Since Unity 5, the RuntimePlatform enum contains WSAPlayerX86, WSAPlayerX64 and WSAPlayerARM and they are now documented. If you're using Unity 5, use those and ignore the rest of this answer. Otherwise, read what follows (the old answer). :)
(in Unity 4)
Unity actually has MetroPlayerX86, MetroPlayerX64 and MetroPlayerARM values defined in the RuntimePlatform enum, but these are not documented for some reason... Some people find them only thanks to IDE auto-completion.
The full enum is defined as follows in Unity 4.5 (my current version):
public enum RuntimePlatform
{
OSXEditor,
OSXPlayer,
WindowsPlayer,
OSXWebPlayer,
OSXDashboardPlayer,
WindowsWebPlayer,
WindowsEditor = 7,
IPhonePlayer,
XBOX360 = 10,
PS3 = 9,
Android = 11,
NaCl,
LinuxPlayer,
FlashPlayer = 15,
MetroPlayerX86 = 18,
MetroPlayerX64,
MetroPlayerARM,
WP8Player,
BB10Player,
BlackBerryPlayer = 22,
TizenPlayer,
PSP2,
PS4,
PSMPlayer,
XboxOne,
SamsungTVPlayer
}
Since they aren't documented, they could theoretically be removed/renamed in future Unity versions (though unlikely, if no alternative is present), but as long as your version has them, they should work.