An interface implemented by a webview if it supports Native 2D Mode, which makes it so that 3D WebView positions a native 2D webview in front of the Unity game view instead of displaying web content as a texture in the Unity scene.
bool Native2DModeEnabled { get; }
Gets a value indicating whether the webview is running in Native 2D Mode.
await canvasWebViewPrefab.WaitUntilInitialized();
var native2DWebView = canvasWebViewPrefab.WebView as IWithNative2DMode;
Debug.Log("Native 2D Mode enabled: " + native2DWebView?.Native2DModeEnabled);
bool Visible { get; }
Gets a value indicating whether the native 2D webview is visible. The default is true
.
void BringToFront()
Brings the native webview to the front of the view hierarchy. A webview is automatically placed in the front when it's created, but this method can be used to control which webview is in front if your scene contains multiple 2D webviews.
await canvasWebViewPrefab.WaitUntilInitialized();
var native2DWebView = canvasWebViewPrefab.WebView as IWithNative2DMode;
native2DWebView?.BringToFront();
This method is currently not supported on UWP.
Task InitInNative2DMode(Rect rect)
Initializes the webview in Native 2D Mode. This method is to be used instead of IWebView.Init() for initialization.
void SetNativeZoomEnabled(bool enabled)
Sets whether the native 2D webview's pinch-to-zoom behavior is enabled. The default is true
.
await canvasWebViewPrefab.WaitUntilInitialized();
var native2DWebView = canvasWebViewPrefab.WebView as IWithNative2DMode;
native2DWebView?.SetNativeZoomEnabled(false);
void SetRect(Rect rect)
Sets the native 2D webview's rect on the screen, in pixels.
void SetVisible(bool visible)
Sets the native 2D webview's rect on the screen, in pixels.