AndroidWebView

class : MonoBehaviour, IWebView

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

Summary

Public methods

ClearHistory

void ClearHistory()

Clears the webview's back / forward navigation history.

GloballyUseAlternativeInputEventSystem

static void GloballyUseAlternativeInputEventSystem(bool useAlternativeInputEventSystem)

Some standalone VR systems (like the Mirage Solo) use a version of Android where the primary system used for dispatching mouse and keyboard events stops working after a while. If you're running on one of those platforms, you can call this method to make webviews use an alternative input event system that doesn't stop working after a while. The tradeoff is that this alternative input event system doesn't handle mouse and keyboard events as accurately as the primary method does (e.g. scrolling in some elements may not work as expected). Note that this is no longer needed for Oculus Go.

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.

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.

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 to the given zoomFactor, which is in the range from 0.01 to 100.0. Note that the zoom level gets reset when a new page is loaded.