static class

Web is the top-level static class for the module. It contains static methods for configuring the module and creating resources.


Public methods


static void ClearAllData()

Clears all data that persists between webview instances, including cookies, storage, and cached resources.


static void CreateTexture(float width, float height, Action<Texture2D> callback)

Creates a special texture that the webview can use for rendering.

Note that the WebViewPrefab takes care of texture creation for you, so you only need to call this method directly if you create IWebView instances outside of a prefab using Web.CreateWebView().

Texture creation occurs asynchronously in order to allow textures to be created on the render thread, and the provided callback is called once the texture has been created.


static IWebView CreateWebView()

Creates a new webview in a platform-agnostic way.

Note that WebViewPrefab takes care of creating an IWebView instance for you, so you only need to call this method directly if you need to create IWebView instances outside of a prefab.


static void SetStorageEnabled(bool enabled)

Controls whether data like cookies, localStorage, and cached resources is persisted between webview instances. The default is true, but this can be set to false to achieve an "incognito mode".


static void SetUserAgent(bool mobile)

By default, webviews use a User-Agent that looks that of a desktop computer so that servers return the desktop versions of websites. If you instead want the mobile versions of websites, you can invoke this method with true to use the User-Agent for a mobile device.


static void SetUserAgent(string userAgent)

Configures the module to use a custom User-Agent string.