#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($“未定义的”); }
正确的理解啥叫预编译宏,你打包的只是你编译的东西