AndroidWebView

class : MonoBehaviour, IWebView

The Android IWebView implementation, which also includes extra methods for Android-specific functionality.

Summary

Public methods

ClearHistory

void ClearHistory()

Clears the webview's back / forward navigation history.

IsWebViewAvailable

static bool IsWebViewAvailable()

Indicates whether the Android WebView package is installed on the system and available.

3D WebView internally depends on Android's WebView package, which is normally installed as part of the operating system. In rare circumstances, the Android WebView package may be unavailable. For example, this can happen if the user used developer tools to delete the WebView package or if updates to the WebView package are currently being installed.

LoadHtml

void LoadHtml(string html, string baseUrl)

Like LoadHtml(string html), but also allows a virtual base URL to be specified.

MovePointer

void MovePointer(Vector2 point)

Moves the pointer to the given point in the webpage. This can be used, for example, to trigger hover effects in the webpage.

The x and y components of the point param are values between 0 and 1 that are normalized to the width and height, respectively. For example, point.x = x in Unity units / width in Unity units. Like in the browser, the origin is in the upper-left corner, the positive direction of the y-axis is down, and the positive direction of the x-axis is right.

Pause

void Pause()

Pauses processing, media, and rendering for this webview instance until Resume() is called.

PauseAll

static void PauseAll()

Pauses processing, media, and rendering for all webview instances. This method is automatically called by the plugin when the application is paused.

Resume

void Resume()

Resumes processing and rendering for all webview instances after a previous call to Pause().

ResumeAll

static void ResumeAll()

Resumes processing and rendering for all webview instances after a previous call to PauseAll(). This method is automatically called by the plugin when the application resumes after being paused.

SetAudioAndVideoCaptureEnabled

static void SetAudioAndVideoCaptureEnabled(bool enabled)

By default, web pages cannot access the device's camera or microphone via JavaScript, even if the user has granted the app permission to use them. Invoking SetAudioAndVideoCaptureEnabled(true) allows all web pages to access the camera and microphone if the user has granted the app permission to use them via the standard Android permission dialogs. This is useful, for example, to enable WebRTC support.

SetInitialScale

void SetInitialScale(float scale)

Sets the initial scale for web content, where 1.0 is the default scale.

SetMediaPlaybackRequiresUserGesture

void SetMediaPlaybackRequiresUserGesture(bool mediaPlaybackRequiresUserGesture)

By default, AndroidWebView prevents JavaScript from auto-playing sound from most sites unless the user has first interacted with the page. You can call this method to disable or re-enable enforcement of this auto-play policy.

SetNativeKeyboardEnabled

static void SetNativeKeyboardEnabled(bool enabled)

Enables or disables the native Android on-screen keyboard for new webviews (the default is disabled).

SetUserAgent

void SetUserAgent(bool mobile)

Like Web.SetUserAgent(bool mobile), except it sets the user-agent for a single webview instance instead of setting it globally.

If you globally set a default user-agent using Web.SetUserAgent(), you can still use this method to override the user-agent for a single webview instance.

SetUserAgent

void SetUserAgent(string userAgent)

Like Web.SetUserAgent(string userAgent), except it sets the user-agent for a single webview instance instead of setting it globally.

If you globally set a default user-agent using Web.SetUserAgent(), you can still use this method to override the user-agent for a single webview instance.

ZoomBy

void ZoomBy(float zoomFactor)

Zooms in or out by the given factor, which is multiplied by the current zoom level to reach the new zoom level. zoomFactor must be in the range from 0.01 to 100.0. Note that the zoom level gets reset when a new page is loaded.