我没有对示例项目进行任何更改。我正在运行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
}
}