IWithNative2DMode

interface

Namespace: Vuplex.WebView

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.

Summary

Public properties

Native2DModeEnabled

bool Native2DModeEnabled { get; }

Gets a value indicating whether the webview is running in Native 2D Mode.

Example

await canvasWebViewPrefab.WaitUntilInitialized();
var native2DWebView = canvasWebViewPrefab.WebView as IWithNative2DMode;
Debug.Log("Native 2D Mode enabled: " + native2DWebView?.Native2DModeEnabled);

Rect

Rect Rect { get; }

Gets the native 2D webview's rect on the screen, in pixels.

Visible

bool Visible { get; }

Gets a value indicating whether the native 2D webview is visible. The default is true.

Public methods

BringToFront

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.

Example

await canvasWebViewPrefab.WaitUntilInitialized();
var native2DWebView = canvasWebViewPrefab.WebView as IWithNative2DMode;
native2DWebView?.BringToFront();

Important note

This method is currently not supported on UWP.

InitInNative2DMode

Task InitInNative2DMode(Rect rect)

Initializes the webview in Native 2D Mode. This method is to be used instead of IWebView.Init() for initialization.

SetNativeZoomEnabled

void SetNativeZoomEnabled(bool enabled)

Sets whether the native 2D webview's pinch-to-zoom behavior is enabled. The default is true.

Example

await canvasWebViewPrefab.WaitUntilInitialized();
var native2DWebView = canvasWebViewPrefab.WebView as IWithNative2DMode;
native2DWebView?.SetNativeZoomEnabled(false);

SetRect

void SetRect(Rect rect)

Sets the native 2D webview's rect on the screen, in pixels.

SetVisible

void SetVisible(bool visible)

Sets the native 2D webview's rect on the screen, in pixels.