Unity不同平台生成中预处理的注意点

Unity3D的项目,这周吃亏在宏上了。大背景是项目需要在Unity中用Hudson自动生成不同平台的版本。

程序设计语言的预处理的概念:在编译之前进行的处理。

#if UNITY_WEBPLAYER
            BuildTarget target = BuildTarget.WebPlayer;
#elif UNITY_STANDALONE_WIN && UNITY_EDITOR
            BuildTarget target = BuildTarget.StandaloneWindows;
#elif UNITY_ANDROID
            BuildTarget target = BuildTarget.Android;
#else
            BuildTarget target = BuildTarget.iPhone;
#endif



#if UNITY_WEBPLAYER
    public const string AssetRootPath = AutomaticBuild.WebPlatFormDataPath + "/";
#elif UNITY_STANDALONE_WIN && UNITY_EDITOR
    public const string AssetRootPath = AutomaticBuild.WinPlatFormDataPath + "/";
#elif UNITY_ANDROID
    public const string AssetRootPath = AutomaticBuild.AndRoidPlatFormDataPath + "/";
#else
    public const string AssetRootPath = AutomaticBuild.IOSPlatFormDataPath + "/";
#endif

如上面两段代码,打开Unity项目(例如PC & Mac Standalone保存的)之后,再打开项目的Script(这里用VS2008+VA),会发现上述加粗行高亮。即Target和AssetRootPath在编译前已然确定,且之后不能对其做出变更。

当采用Unity支持的命令编译时C:\program files\Unity\Editor>Unity.exe -quit -batchmode -executeMethod MyEditorScript.MyMethod

此时MyMethod可能用了如下代码,

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值