Download the Google VR SDK for Unity
- Download the latest
GoogleVRForUnity_*.unitypackage
from the releases page.
Enabling see-through mode via the Unity prefab
- Add the GoogleVR > Beta > Prefabs > GvrBetaHeadset prefab to your scene.
Note:
GvrBetaHeadset
supersedesGvrHeadset
. If theGvrHeadset
prefab is present in your scene, remove it. - Select the
GvrBetaHeadset
object in the scene. - Using the component inspector for
GvrBetaHeadset
, configure see-through mode to be used at the startup of your scene.
Enabling see-through mode via APIs
Check to see if the system supports see-through mode and if it is enabled using the class
GvrBetaSettings
, its methodsIsFeatureSupported(...)
andIsFeatureEnabled(...)
, and the enumGvrBetaFeature.SeeThrough
.If it is supported but not enabled, request the user enable it by calling
GvrBetaSettings.RequestFeatures(...)
with an array containing the enumGvrBetaFeature.SeeThrough
.bool supported = GvrBetaSettings.IsFeatureSupported(GvrBetaFeature.SeeThrough); bool enabled = GvrBetaSettings.IsFeatureEnabled(GvrBetaFeature.SeeThrough); if (supported && !enabled) { GvrBetaFeature[] features = new GvrBetaFeature[] { GvrBetaFeature.SeeThrough }; GvrBetaSettings.RequestFeatures(features, null); }
The
GvrBetaHeadset
class provides theCameraMode
andSceneType
properties that let you set see-through mode and scene type, respectively. You can also useSetSeeThroughConfig
to set both properties simultaneously.GvrBetaHeadset.SetSeeThroughConfig(GvrBetaSeeThroughCameraMode.RawImage, GvrBetaSeeThroughSceneType.Virtual);
To ensure your scene composites with see-through mode properly, make sure the Clear Flags option for the main camera is set to Solid Color and the Background color is set to black with 0 Alpha.