【发布时间】:2015-09-12 18:36:39
【问题描述】:
我没有对示例项目进行任何更改。我正在运行 Unity 5.0.2f1。当我尝试为 Google Cardboard for ios 构建演示项目时,它说它无法构建,因为脚本存在编译器错误。它显示了两个编译器错误:
Assets/Cardboard/Editor/CardboardEditor.cs(128,42):error CS0117: 'UnityEditor.PlayerSettings' does not contain a definition for 'GetGraphicsAPIs'
和
Assets/Cardboard/Editor/CardboardEditor.cs(130,5): error CS1579: foreach statement cannot operate on variables of type 'object' because it does not contain a definition for 'GetEnumerator' or is not accessible
我假设解决第一个错误将解决第二个错误。引发错误的代码如下所示:
private static void CheckGraphicsAPI() {
#if UNITY_IOS
#if UNITY_5 || UNITY_4_6 && !UNITY_4_6_1 && !UNITY_4_6_2
#if UNITY_5
var iOSBuildTarget = BuildTarget.iOS;
var iOSGraphicsAPIs = PlayerSettings.GetGraphicsAPIs(BuildTarget.iOS);
bool isOpenGL = true;
foreach (var device in iOSGraphicsAPIs) {
isOpenGL &= (device == GraphicsDeviceType.OpenGLES2 || device == GraphicsDeviceType.OpenGLES3);
}
#else
var iOSBuildTarget = BuildTarget.iPhone;
bool isOpenGL = PlayerSettings.targetIOSGraphics == TargetIOSGraphics.OpenGLES_2_0
|| PlayerSettings.targetIOSGraphics == TargetIOSGraphics.OpenGLES_3_0;
#endif // UNITY_5
if (EditorUserBuildSettings.activeBuildTarget == iOSBuildTarget
&& !Application.isPlaying
&& Object.FindObjectOfType<Cardboard>() != null
&& !isOpenGL) {
Debug.LogWarning("iOS Graphics API should be set to OpenGL for best " +
"distortion-correction performance in Cardboard.");
}
#endif // UNITY_5 || UNITY_4_6 && !UNITY_4_6_1 && !UNITY_4_6_2
#endif // UNITY_IOS
}
}
【问题讨论】:
-
更新 Xcode,也许吧?
-
在我尝试统一构建项目时发生错误,在将其放入 xcode 之前。
标签: google-cardboard