因为Windows Phone的版本和 Runtime 一直比较混乱,所以宏定义项也比较多:
UNITY_WP8 | 只用于 Windows Phone 8.0 apps ; |
UNITY_WP_8_1 | 用于 Windows Phone 8.1 和 Universal 8.1 apps ,运行在 Windows phone 设备上时; |
UNITY_METRO | 用于 Windows Phone 8.1, Windows Store 8.0, Windows Store 8.1 和 Universal 8.1 apps; |
UNITY_METRO_8_0 | 用于 Windows Store 8.0 apps; |
UNITY_METRO_8_1 | 用于 Windows Store 8.1 和 Universal 8.1 apps,运行在 Windows 设备上时; |
UNITY_WINRT | 用于 Windows Phone 和 Windows Store apps, 不考虑版本; |
UNITY_WINRT_8_0 | 用于 Windows Phone 8.0 和 Windows Store 8.0 apps; |
UNITY_WINRT_8_1 | 用于 Windows Phone 8.1, Windows Store 8.1 和 Universal apps,不考虑设备类型; |
NETFX_CORE | 用于 Windows Store 8.0, Windows Store 8.1, Windows Phone 8.1 和 Universal 8.1 ,用微软的C#编译器编译的脚本 |
导出的WP8.1项目默认的宏定义是:
NETFX_CORE;UNITY_METRO;UNITY_WP_8_1
而在Unity Editor中的带有的宏定义是:
UNITY_EDITOR
宏定义:UNITY_METRO
用于WP8.1时的任何脚本。
宏定义:NETFX_CORE
仅用于不在Asset\Plugins,Assets\Standard Assets, Assets\Pro Standard Assets这3个目录下的C#脚本,并且当编译选项设置为 Use NET Core 时才管用。
http://forum.unity3d.com/threads/when-using-net-core-i-receive-errores-about-denote-not-valid-type.237245/
http://forum.unity3d.com/threads/windows-store-validation-a-few-questions.217847/
http://answers.unity3d.com/questions/579641/handling-the-lack-of-systemio-classes-in-windows-8.html
Assets\Plugins\Metro ,用于Windows Phone 8.1 和Windows Store 8.0/8.1 apps;
或者其子文件夹:
Assets\Plugins\Metro\Win80 ,用于Windows Store 8.0 apps;
Assets\Plugins\Metro\Win81 ,用于Windows Store 8.1 apps
Assets\Plugins\Metro\WindowsPhone81 ,用于Windows Phone 8.1 apps
注意:不支持Silverlight类型的Windows Phone 8.1 apps
注意:Unity的多平台支持不仅包括IOS、Android、WP等,还包括Unity自己的Editor。所以不能在Unity Editor中测试.NET CORE/WinRT的API,因为Unity Editor不支持,当然了,JS文件中也不支持。只能用if #NETFX_CORE && !UNITY_EDITOR 把代码包起来,防止编译错误。
可以做两个版本的DLL,一个放在Assets\Plugins\MyPlugin.dll下,用于兼容UNITY的EDITOR ,另一个放在Assets\Plugins\Metro\MyPlugin.dll,用于兼容商店应用。两个DLL的名称必须相同。