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

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


#如果UNITY_WEBPLAYER
,,,,,,BuildTarget目标=BuildTarget.WebPlayer;
# elif UNITY_STANDALONE_WIN,,UNITY_EDITOR
,,,,,<>强才能BuildTarget目标=BuildTarget.StandaloneWindows;
# elif UNITY_ANDROID
,,,,,,其他BuildTarget目标=BuildTarget.Android;
#
,,,,,,# endif BuildTarget目标=BuildTarget.iPhone;



#如果UNITY_WEBPLAYER
,,AssetRootPath=AutomaticBuild公共常量字符串。WebPlatFormDataPath & # 43;“/?br> # elif UNITY_STANDALONE_WIN,,UNITY_EDITOR
,<>强才能AssetRootPath=AutomaticBuild公共常量字符串。WinPlatFormDataPath & # 43;“/?/强>
# elif UNITY_ANDROID
,,AssetRootPath=AutomaticBuild公共常量字符串。AndRoidPlatFormDataPath & # 43;“/?br> #
其他,,AssetRootPath=AutomaticBuild公共常量字符串。IOSPlatFormDataPath & # 43;“/?br> # endif

如上面两段代码,打开统一项目(例如电脑,Mac独立保存的)之后,再打开项目的脚本(这里用vs2008 # 43; VA),会发现上述加粗行高亮。即目标和AssetRootPath在编译前已然确定,且之后不能对其做出变更。


 

SwitchActiveBuildTarget(目标:,BuildTarget)函数。

由于需求的小变更,小小地重构了上次的代码:















































































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