November 6, 2019 update:
  • There's a new open source Cardboard SDK for iOS and Android NDK that offers a streamlined API, improved device compatibility, and built-in viewer profile QR code scanning. A corresponding Unity package (SDK) is planned for a future release. We recommend that all developers actively building for Google Cardboard migrate (iOS, Android NDK) to the new Cardboard SDK.
October 15, 2019 update:
  • The Daydream View VR headset is no longer available for purchase. However, you can continue to use the existing Google VR SDK to update and distribute your apps to the Google Play Store, and make them available to users in the Daydream app.

GVRCardboardView Class

GVRCardboardView Class Reference

Overview

Defines a view responsible for rendering graphics in VR mode.

It is designed to work in full screen mode with a landscape orientation. It provides all the transition between mono and stereo (VR) modes. The view switches to fullscreen VR mode when vrModeEnabled property is set to YES. The developer should ensure UISupportedInterfaceOrientations key in the application's plist file includes UIInterfaceOrientationPortrait and UIRequiresFullscreen is set to YES.

The users of this class provide an implementation of the GVRCardboardViewDelegate protocol through the delegate property. The methods in the protocol GVRCardboardViewDelegate are called to perform the actual rendering of the graphics.

In order to drive the rendering, the users of this class should call the render method from their render loop. The thread used to call the render method is refered to as the GL thread. This thread, in turn, calls the method of the GVRCardboardViewDelegate protocol.

Inherits UIView.

Instance Method Summary

(instancetype) - initWithFrame:
 Designated initializer. More...
 
(void) - render
 Drives the rendering of the cardboard view. More...
 

Class Method Summary

(void) + setViewerParamsFromUrl:withCompletion:
 Sets the Cardboard viewer parameters from a Url. More...
 

Property Summary

id< GVRCardboardViewDelegatedelegate
 Delegate to be notified of cardboard view rendering. More...
 
EAGLContext * context
 The OpenGL context used for rendering. More...
 
BOOL vrModeEnabled
 The vrModeEnabled property allows switching to and from VR mode. More...
 
BOOL hidesTransitionView
 Flag to hide or show the transition view when in VR mode. More...
 

Method Detail

- (instancetype) initWithFrame: (CGRect)  NS_DESIGNATED_INITIALIZER

Designated initializer.

- (void) render

Drives the rendering of the cardboard view.

Call this from your app's render loop.

+ (void) setViewerParamsFromUrl: (NSURL *)  url
withCompletion: (void(^)(BOOL success, NSError *error))  completion 

Sets the Cardboard viewer parameters from a Url.

This allows programmatically pairing a viewer without having the user go through the pairing flow. Calls the supplied completion handler with the result of pairing and the error if it fails.

Note: The viewer parameters can be set only if no other viewer pairing exists. In other words, this only works if the user hasn't already paired a viewer for the current application.

A valid viewer parameters URI can be generated from this page: https://www.google.com/get/cardboard/viewerprofilegenerator/

Property Detail

- (id<GVRCardboardViewDelegate>) delegate
readwritenonatomicweak

Delegate to be notified of cardboard view rendering.

- (EAGLContext*) context
readwritenonatomicassign

The OpenGL context used for rendering.

Defaults to OpenGL ES3 context, if not set.

- (BOOL) vrModeEnabled
readwritenonatomicassign

The vrModeEnabled property allows switching to and from VR mode.

When set to YES, the cardboard view transitions into a fullscreen view to allow the user to place the device into the Cardboard viewer. When set to NO, it transitions back to pre-VR (mono) mode.

- (BOOL) hidesTransitionView
readwritenonatomicassign

Flag to hide or show the transition view when in VR mode.