把现有Unity3d游戏向Windows Phone 8.1移植(宏编译)

因为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#编译器编译的脚本
所有宏定义:http://docs.unity3d.com/Manual/PlatformDependentCompilation.html

导出的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


而用于Windows Phone 和 Windows 商店应用的脚本应该放在下面的目录之下:

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的名称必须相同。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值