IWebView is the primary interface for loading and interacting with web content.


Public methods


void Blur()

Makes the webview relinquish focus.


void Click(Vector2 point)

Clicks at the given point in the webpage. The point's coordinates are relative to the origin at the page's top left corner. Its x and y components 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.


void DisableViewUpdates()

Disables the webview from rendering to its texture.


void Dispose()

Destroys the webview, releasing all of its resources.


void EnableViewUpdates()

Re-enables rendering after a call to DisableViewUpdates().


void ExecuteJavaScript(string javaScript)

Executes the given script in the context of the webpage's main frame.


void Focus()

Makes the webview take focus. Currently, this method is only needed on iOS.


void HandleKeyboardInput(string key)

Executes the given script in the context of the webpage's main frame. A key is either a single character representing a unicode character (e.g. 'A', 'b', '?') or multiple characters representing a control key (e.g. 'ArrowUp', 'ArrowLeft').


void Init(Texture2D texture, float width, float height)

Initializes a newly created webview given a texture created by ITextureCreator and the dimensions in Unity units.


void LoadHtml(string html)

Loads the webpage contained in the given HTML string.


webView.LoadHtml(@"<!DOCTYPE html>
      <title>Test Page</title>
        h1 {
          font-family: Helvetica, Arial, Sans-Serif;
      <h1>LoadHtml Example</h1>
        console.log('This page was loaded!');


void LoadUrl(string url)

Navigates to the given URL. Note that this can also be a file URL that points to a local file in the Android or iOS application bundle. For example, you can assemble a file URL on Android if you know the path to the resource:


On iOS, you must ask the system for a file URL to a given bundle resource. iOSWebView has a static GetFileUrlForBundleResource() method that can do this for you.


void PostMessage(string data)

Posts a message that JavaScript within the webview can listen for using window.vuplex.addEventListener('message', function(message) {}). The provided data string is passed as the data property of the message object.


void Reload()

Reloads the current page.


void Resize(float width, float height)

Resizes the webview to the dimensions given in Unity units


void ZoomIn()

Zooms into the web content.


void ZoomOut()

Zooms back out after a previous call to ZoomIn().

Public events


EventHandler<ProgressChangedEventArgs> LoadProgressChanged

Indicates that the page load percentage changed.


EventHandler<EventArgs<string>> MessageEmitted

Indicates that JavaScript running in the page used the window.vuplex.postMessage JavaScript API to emit a message to the Unity application.

JavaScript example for sending a message:

function sendMessageToCSharp() {
  // This object passed to `postMessage()` is automatically serialized as JSON
  // and is emitted via the C# MessageEmitted event. This API mimics the window.postMessage API.
  window.vuplex.postMessage({ type: 'greeting', message: 'Hello from JavaScript!' });

if (window.vuplex) {
  // The window.vuplex object has already been initialized after page load,
  // so we can go ahead and send the message.
} else {
  // The window.vuplex object hasn't been initialized yet because the page is still
  // loading, so add an event listener to send the message once it's initialized.
  window.addEventListener('vuplexready', sendMessageToCSharp);


EventHandler<EventArgs<Texture2D>> TextureChanged

Indicates that an update occurred that caused the webview to discard its existing texture and start using the new texture emitted in this event.

Currently, this event is only used for iOS when a resize occurs (it's not used on Android). WebViewPrefab automatically handles this event by applying thew new texture to the ViewportMaterialView. If you're not using the prefab, then you'll have to manually handle this event like it does.


EventHandler<EventArgs<string>> TitleChanged

Indicates that the page's title changed.


EventHandler<UrlChangedEventArgs> UrlChanged

Indicates that the URL of the webview changed, either due to user interaction or JavaScript.