How can I get clicking and scrolling to work?

Symptoms

Cause

Resolution

3D WebView's prefabs automatically detect input from Unity's Event System like described in this article.

A scene must include two things in order for clicking and scrolling to work:

  • The scene must include an Event System with an input module
  • The main camera must have a Physics Raycaster attached to it (or in the case of CanvasWebViewPrefab, the Canvas must have a Graphic Raycaster attached)

3D WebView's demo scenes use Unity's StandaloneInputModule, which works great for desktop and mobile applications. For virtual and augmented reality, your VR or AR SDK usually includes an input module. For reference, please see this list of input modules and following webview example projects:

If an example project isn't listed for your VR or AR SDK, then the following tips may be helpful:

  • Search your VR or AR SDK for a demo scene that demonstrates interacting with a UI Canvas. If you locate such a scene, try adding a CanvasWebViewPrefab to the scene's Canvas. You can also try adding a PhysicsRaycaster to the scene's main camera and adding a WebViewPrefab to the scene.
  • Search your SDK's documentation or files for the terms "InputModule" or "IPointerClickHandler" to locate information about its input module.

If your project or SDK implements its own proprietary event system that isn't compatible with Unity's event system, you can still enable clicking by using the approaches described here.