How does clicking and scrolling work?

3D WebView's prefabs (WebViewPrefab and CanvasWebViewPrefab) have a built-in input detector that automatically detects user input like clicking, dragging, and scrolling from the following sources:

Additionally, applications can customize how clicks are detected by using the approaches described in this section. For troubleshooting tips, please see this article.

Unity's Event System

The prefabs' default input detectors listen for standard events sent through Unity's Event System, like IPointerDownHandler and IScrollHandler. So, they automatically work with input modules that send those standard events. Here are some of the compatible input modules:

Mixed Reality Toolkit (MRTK)

The prefabs' default input detectors also automatically detect input sent through MRTK's input system. They do this by implementing IMixedRealityPointerHandler, so they automatically receive input events from MRTK. They also detect touch interactions by adding a NearInteractionTouchable to the prefab.

Custom input detection

In rare cases, you may need to customize how 3D WebView's prefabs detect pointer input. For example, if your project uses a VR SDK that implements its own proprietary event system (like VRTK) instead of using Unity's event system, then the prefabs won't be able to automatically detect input. In a case like that, there are a couple of options for enabling 3D WebView's prefabs to receive input:

  1. The first option is to implement a custom IPointerInputDetector and then pass it to WebViewPrefab.SetPointerInputDetector(), like this:
var customInputDetector = webViewPrefab.Collider.gameObject.AddComponent<YourCustomInputDetector>();
webViewPrefab.SetPointerInputDetector(customInputDetector);
  1. Another option is to call IWebView methods directly on WebViewPrefab.WebView, like this:
webViewPrefab.WebView.Click(point);
webViewPrefab.WebView.Scroll(delta, point);