public void StartCardboard() { // Configures the app to not shut down the screen and sets the brightness to maximum. // Brightness control is expected to work only in iOS, see: // https://docs.unity3d.com/ScriptReference/Screen-brightness.html. Screen.sleepTimeout = SleepTimeout.NeverSleep; Screen.brightness = 1.0f; Application.targetFrameRate = 60; if (!loader) { loader = ScriptableObject.CreateInstance <XRLoader>(); } #if !UNITY_EDITOR loader.Initialize(); #endif loader.Start(); ConnectCardboardInputSystem(); isStarted = true; ReloadDeviceParams(); // Checks if the device parameters are stored and scans them if not. if (!Api.HasDeviceParams()) { Api.ScanDeviceParams(); } }
/// <summary> /// Updates screen parameters. This method must be called at framerate to ensure the safe /// area is properly taken into account on iOS devices. /// /// Note: This method is a workaround for /// <a href=https://fogbugz.unity3d.com/default.asp?1288515_t9gqdh39urj13div>Issue #1288515</a> /// in Unity. /// </summary> public static void UpdateScreenParams() { // TODO(b/171702321): Remove this method once the safe area size could be properly // fetched by the XRLoader. if (!XRLoader._isInitialized) { return; } // Only recalculate rectangles if safe area size has changed since last check. if (_cachedSafeArea != Screen.safeArea) { _cachedSafeArea = Screen.safeArea; XRLoader.RecalculateRectangles(_cachedSafeArea); } }