#if UNITY_EDITOR Debug.Log("Unity Editor"); #elif UNITY_IOS Debug.Log("Unity iPhone"); #else Debug.Log("Any other platform"); #endif
打包apk。还是会执行 Debug.Log("Unity Editor");
Debug.Log("Unity Editor");
这个问题是为啥,如何处理来实现区分平台。
流砂一指 我也遇到这个问题了,你后来找到原因了吗?
switch (Application.platform) { case RuntimePlatform.Android: break; case RuntimePlatform.WindowsEditor: break; case RuntimePlatform.LinuxEditor: break; case RuntimePlatform.OSXEditor: break; default: throw new ArgumentOutOfRangeException($“未定义的”); }
正确的理解啥叫预编译宏,你打包的只是你编译的东西
Mainpulation 没太明白你说的啥意思。问题是打包出来的apk为什么会执行 UNITY_EDITOR 宏内的代码,正常打包apk的时候这些代码不应该都不会打进包里吗?