User Guide
Prerequisites
Unity Version
| Unity Version | Status |
|---|---|
| Unity 6 (6000.x) | Recommended — fully tested with 6000.3.3f1 |
| Unity 2022.3 LTS | Supported (minimum) |
| Unity 2023.x | Supported |
| Unity 2021.x or earlier | Not supported |
Scripting Backend
| Backend | Status |
|---|---|
| IL2CPP | Recommended for all platforms |
| Mono | Supported on desktop (Windows, macOS, Linux) |
Platform Runtime Requirements
| Platform | Requirement | Pre-installed? |
|---|---|---|
| Windows 10/11 | WebView2 Runtime (Edge Chromium) | Yes — ships with Windows 10 April 2018+ and all Windows 11 |
| Android 7.0+ | Android System WebView | Yes — bundled since API 24, auto-updated via Play Store |
| iOS 14+ | WKWebView (WebKit.framework) | Yes — part of iOS |
| macOS 11+ | WKWebView (WebKit.framework) | Yes — part of macOS |
| Linux | libwebkit2gtk-4.1 + libgtk-3 | No — install via package manager |
Linux install:
sudo apt install libwebkit2gtk-4.1-0 libgtk-3-0(Ubuntu/Debian) orsudo dnf install webkit2gtk4.1 gtk3(Fedora)
Installation
- Purchase and download Lightweight Browser from the Unity Asset Store
- In Unity, open Window → Package Manager
- Select My Assets, find Lightweight Browser, and click Import
- The package will appear under Packages in your project
Quick Start
Option A: Use the Sample Scene
- After importing, go to Package Manager → Lightweight Browser → Samples
- Import the Basic Browser sample
- Open the imported
BasicBrowserScene - Press Play
Option B: Add to Any Scene
- Create an empty GameObject
- Add the Hexora → Lightweight Browser component
- Set Home URL in the Inspector (e.g.
https://www.google.com) - Press Play — a fullscreen browser with auto-generated Canvas appears
Inspector Reference
LightweightBrowser Component
Browser Settings
| Field | Description | Default |
|---|---|---|
| Home URL | The URL loaded on startup and when pressing Home | https://www.google.com |
| Normalised Rect | Browser position/size. Values 0–1 are normalised (percentage of screen). Values > 1 are absolute pixels. Set to (0,0,0,0) for fullscreen with auto toolbar offset. | (0, 0, 0, 0) |
Display
| Field | Description | Default |
|---|---|---|
| Display Image | Optional RawImage to render the web page into. If left empty, one is auto-created with a Canvas. | None |
| Zoom Enabled | Allow Ctrl+scroll (desktop) or pinch-to-zoom (mobile) | false |
Debugging
| Field | Description | Default |
|---|---|---|
| Debugging Enabled | Enable remote debugging (DevTools on Windows, Safari Web Inspector on Apple) | false |
| Bridge Enabled | Enable the JavaScript ↔ C# bridge system | false |
| Debug Overlay Enabled | Show the IMGUI debug overlay for bridge message inspection (requires Bridge Enabled) | false |
ScreenResizeHandler Component
Automatically detects screen resolution changes and resizes the browser to match. Add to the same GameObject as LightweightBrowser.
| Field | Description | Default |
|---|---|---|
| Browser | Reference to the LightweightBrowser (auto-detected if on same GameObject) | Auto |
| Poll Interval | How often to check for resolution changes (seconds) | 0.15 |
Display Modes
Texture Mode (Default)
The web page is captured as a Texture2D and displayed on a Unity RawImage. This allows:
- Unity UI elements to render on top of the browser
- The browser to be part of the normal Unity UI layout
- Mouse/keyboard input forwarding from Unity to the browser
Rect Configuration
The Normalised Rect field supports two modes:
| Value Range | Mode | Example |
|---|---|---|
| 0.0 – 1.0 | Normalised — percentage of screen | (0, 0.05, 1, 0.95) = full width, 95% height with 5% top offset |
| > 1 | Absolute pixels | (0, 56, 1920, 1024) = starts at Y=56px |
(0, 0, 0, 0) | Auto fullscreen — fills screen below the toolbar (56px offset) | Default |
Navigation
From Inspector / UI
The sample BasicBrowserController provides a toolbar with:
- URL bar — type a URL and press Enter or click Go
- Back / Forward — browser history navigation
- Reload — reload current page
- Home — navigate to configured Home URL
From C# Script
using Hexora.LightweightBrowser;
public class MyScript : MonoBehaviour
{
[SerializeField] private LightweightBrowser _browser;
void Start()
{
_browser.LoadUrl("https://unity.com");
}
void OnGUI()
{
var wv = _browser.WebView;
if (wv != null)
{
GUILayout.Label($"URL: {wv.CurrentUrl}");
GUILayout.Label($"Title: {wv.Title}");
GUILayout.Label($"Loading: {wv.IsLoading}");
}
}
}
URL Changed Events
void OnEnable()
{
_browser.WebView.UrlChanged += OnUrlChanged;
_browser.WebView.PageFinished += OnPageFinished;
_browser.WebView.TitleChanged += OnTitleChanged;
}
void OnUrlChanged(string url) => Debug.Log($"Navigated to: {url}");
void OnPageFinished(string url) => Debug.Log($"Page loaded: {url}");
void OnTitleChanged(string title) => Debug.Log($"Title: {title}");
WebViewmay benullduringAwake(). Subscribe inStart()or check with_browser.WebView?.UrlChanged += ....
Input Handling
On desktop platforms (Windows, macOS, Linux), the plugin captures the web page as a texture and forwards input events:
- Mouse — click, move, scroll (forwarded based on RawImage position)
- Keyboard — key down/up and character events (forwarded when browser has focus)
The InputForwarder component handles this automatically.
Remote Debugging
Windows
- Set Debugging Enabled =
truein the Inspector - Press Play
- Open
edge://inspectin Microsoft Edge - Your webview appears under “Other targets”
macOS / iOS
- Set Debugging Enabled =
true - Open Safari → Develop menu
- Select your app → web page
Android
- Set Debugging Enabled =
true - Open
chrome://inspectin Chrome - Your webview appears under “Remote Target”
Bridge Debug Overlay
When Bridge Enabled and Debug Overlay Enabled are both checked:
- Press F12 (desktop) or triple-tap (mobile) to toggle
- Shows all bridge messages in real-time with colour coding:
- 🔵 Commands (C# → WebView)
- 🟢 Events (WebView → C#)
- 🟡 Calls (JS → C#)
- 🟣 Responses
- 🔴 Errors
- Filter by text, clear buffer, copy to clipboard
Best Practices
- One browser per scene — Only one
LightweightBrowserinstance is supported. - Destroy on scene unload — The native webview is destroyed in
OnDestroy(). Automatic withLoadSceneMode.Single. - DontDestroyOnLoad — If you need persistence across scenes, call
DontDestroyOnLoad(gameObject). - Thread safety — All
IWebViewmethods must be called from the Unity main thread. - URL scheme — Always use
https://.http://may be blocked on Android and iOS by default.