3D WebView has two different modes for rendering web content:
Default mode (supported on all platforms except WebGL):
- Web content from the browser engine is rendered to a texture that is displayed in the Unity scene.
- User interactions (like clicking, scrolling, and dragging) are detected through Unity and then relayed to the browser engine.
- Supports both 3D and 2D webviews.
Native 2D Mode (Android, iOS, and WebGL only):
Enabling Native 2D Mode
Native 2D Mode is supported by the following 3D WebView packages:
If the 3D WebView package in use doesn't support Native 2D Mode, then the default rendering mode is used instead. When Native 2D Mode is enabled, you can still control a webview just like you can with the default rendering mode:
- Add a CanvasWebViewPrefab to a Canvas and position it like a regular UI element by adjusting its Rect Transform.
- Utilize IWebView APIs using the CanvasWebViewPrefab.WebView property, like this:
Benefits of Native 2D Mode
- Better performance on iOS, because Native 2D Mode is much faster than the default rendering mode.
- Better image quality out-of-the-box, because it uses the device's native pixel density.
- Better scrolling, because it uses the native scroll momentum.
- Support for multitouch gestures, like pinch-to-zoom.
Limitations of Native 2D Mode
Since Native 2D Mode works by positioning a native 2D webview in front of the Unity game view, Unity objects or other UI elements cannot be placed in front of the webview. So, if you need the webview to be placed behind another object, please disable Native 2D Mode to use the default rendering mode instead.
Native 2D Mode currently requires that the Canvas's render mode be set to "Screen Space - Overlay". If the Canvas is set to a different render mode, 3D WebView's default rendering mode will be used instead.
Native 2D Mode isn't supported on VR or AR headsets.
In order to display hardware-accelerated content like video and WebGL in Native 2D Mode on Android, 3D WebView automatically enables hardware acceleration for the app. However, you can disable this by adding the scripting symbol
VUPLEX_ANDROID_DISABLE_HARDWARE_ACCELERATIONin your Android player settings.
The following APIs are unsupported or ignored in Native 2D Mode: