This Unity project demonstrates how to use Vuplex 3D WebView with Unity's XR Interaction Toolkit (XRI). It includes XRI and its dependencies, so all you need to do is import 3D WebView into the project. Please note that input with XRI requires 3D WebView's CanvasWebViewPrefab. XRI input with the non-canvas WebViewPrefab is not supported.
-
Created a new project with Unity 6 (6000.0.21).
-
Imported the following via the Package Manager:
- XR Interaction Toolkit (com.unity.xr.interaction.toolkit) v3.0.7
- From the "Samples" tab of the XR Interaction Toolkit package, imported the "Start Assets" sample.
- 3D WebView for Android (omitted from this repo via the .gitignore)
-
Created a copy of the DemoScene.unity scene from the XRI Starter Assets sample, which I named XRInteractionWebViewExample.unity:
cp "Assets/Samples/XR Interaction Toolkit/3.0.7/Starter Assets/DemoScene.unity" Assets/Scenes/XRInteractionWebViewExample.unity
-
Made the following changes to the new XRInteractionWebViewExample.unity scene:
- Added a CanvasWebViewPrefab and CanvasKeyboard to the scene's UI Sample canvas.
- Added a "Scripting API Example" object with an XRInteractionWebViewExample.cs script that demonstrates how to use 3D WebView's scripting APIs.
- Removed all objects from the scene that aren't necessary for demonstrating interaction with the webview.
- Modified the color settings of the controllers' LineVisual objects to make the controller ray easier to see.
-
In Project Settings -> XR Plugin Management:
- Clicked "Install XR Plugin Management".
- In the Android tab -> Plug-in Providers, enabled Oculus.
3D WebView's prefabs detect input through Unity's event system like described in this article. In the case of XR Interaction Toolkit, the scene's XRUIInputModule sends input through Unity's event system, which 3D WebView's prefabs then detect. If your CanvasWebViewPrefab and CanvasKeyboard aren't responding to clicks or scrolling, then that indicates that your scene is not configured correctly. I recommend using this project as a reference and verifying the following settings in your scene:
- The canvas must have a TrackedDeviceGraphicRaycaster attached to it.
- The canvas's Event Camera must be set to the scene's main camera.