unity 判断平台(安卓,iOS还是编辑器)

时间:2018-09-18 11:54:15   收藏:0   阅读:2411

两种方式

--------------- C预处理器编译判断 ---------------

#if UNITY_IOS
// ... iOS项目才会编译
#elif UNITY_ANDROID
// ... apk 或 iOS项目才会编译
#elif UNITY_EDITOR
// ... UNITY调试时候才编译
#endif

 

--------------- 代码运行时判断 ---------------

if(Application.platform == RuntimePlatform.Android)
{
//只有在安卓生效
}

 

:)

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!