【问题标题】:When trying to build the Google Cardboard demo project for ios, it fails citing compiler error尝试为 ios 构建 Google Cardboard 演示项目时,引用编译器错误失败
【发布时间】: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


【解决方案1】:

此功能只是想提醒您,如果您想在 SDK 中使用原生 (C++) 失真校正,则 Player Settings 中的 Graphics API 必须是 OpenGL(即不是 Metal)。

如果您已经知道(或不在乎),那么您可以通过注释掉此函数的主体来解决该错误。

(Unity 已经在多个增量版本中更改了用于检查图形 API 的枚举和函数。因此这些错误不断出现,Cardboard SDK 必须在下一个版本中赶上。)

【讨论】:

    猜你喜欢
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多