com.gmonks.webview
v1.1.0
Published
A WebView library for Unity Android platform, providing a simple way to display web content within Unity applications.
Readme
WebView for Unity
A Unity package for embedding web content in your Unity projects.
Features
- Display web pages inside Unity
- JavaScript and C# communication
- Supports Android Platform only
Installation
Option 1: Using Unity Package Manager with Scoped Registry
- Open your Unity project.
- Go to Edit > Project Settings > Package Manager > Scoped Registries.
- Click + to add a new scoped registry and enter:
- Name: GMonks
- URL:
https://registry.npmjs.org - Scope(s):
com.gmonks
- Click Save.
- After adding the scoped registry, the package should appear in the Package Manager under the registry's name.
- Locate
com.gmonks.webviewin the list, select it, and choose the desired version to install. - Click Install.
Option 2: Modify manifest.json Directly
Open your project folder and navigate to
Packages/manifest.json.Add or update the
scopedRegistriessection:"scopedRegistries": [ { "name": "GMonks", "url": "https://registry.npmjs.org", "scopes": [ "com.gmonks" ] } ],Add the package to the
dependenciessection:"com.gmonks.webview": "x.y.z"Replace
x.y.zwith the specific version you want to install, as listed in the package registry or release notes.Save the file and return to Unity. The package will be installed automatically.
Usage
Here's a basic example of how to use the WebView package in your Unity project:
Create a
WebViewinstance in your script.
TheWebViewis used as a class object and does not require a prefab. You can instantiate and control it directly from your code, as shown below.Create a script to control the WebView.
For example, you can use the following pattern:using GMonks.WebViewLib; public class WebViewDemo : MonoBehaviour, IWebViewEventListener { [SerializeField] private Button loadWebViewBtn; [SerializeField] private string webUrl = "https://google.com/"; private WebView webView; private void Awake() { webView = new(); loadWebViewBtn.onClick.AddListener(() => { webView.OpenURL(webUrl, GetOptions()); }); } private void OnEnable() => webView.EventHandler.AddListener(this); private void OnDisable() => webView.EventHandler.RemoveListener(this); private void OnDestroy() => webView.CloseWebView(); // Implement IWebViewEventListener methods as needed public void OnWebViewFinishedLoading(string url) { /* ... */ } public void OnWebViewClosed() { /* ... */ } // See full example for more event handlers private DisplayOptions GetOptions() { return new DisplayOptions() { insets = new EdgeInsets(0, 0, 0, 0), setLoadWithOverviewMode = true, shouldUseWideViewPort = true, hidesTopBar = true, browserBackgroundColor = "#FFFFFF", hidesHistoryButtons = true, backButtonCustomBehaviour = true, webContentsDebuggingEnabled = true, pinchAndZoomEnabled = false, }; } }Implement the
IWebViewEventListenerinterface to handle events such as loading, errors, closing, and JavaScript callbacks.Configure the WebView options using the
DisplayOptionsclass to customize appearance and behavior.Use Unity UI elements (like a Button) to trigger WebView actions.
Support
This package is maintained by GMonks Entertainment Private Limited.
For support, please contact the package maintainer directly.
© 2014-2025 GMonks Entertainment Pvt. Ltd. All Rights Reserved.
