Reputation: 510
I made no changes to the sample project. I'm running Unity 5.0.2f1. When I try to build the demo project for Google Cardboard for ios, it says it can't build because scripts have compiler errors. It shows two compiler errors:
Assets/Cardboard/Editor/CardboardEditor.cs(128,42):error CS0117: 'UnityEditor.PlayerSettings' does not contain a definition for 'GetGraphicsAPIs'
and
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
I assume that solving the first error will solve the second. The code that's throwing the errors looks like this:
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
}
}
Upvotes: 0
Views: 370
Reputation: 839
This function is just trying to remind you that if you want to use the native (C++) distortion correction in the SDK, that the Graphics API in Player Settings has to be OpenGL (i.e. not Metal).
If you already know that (or don't care) then you can work around the error by commenting out the body of this function.
(Unity has been changing their enums and functions for checking the Graphics API over several incremental releases. So these errors keep coming up, and the Cardboard SDK has to play catch-up on the next release.)
Upvotes: 1