Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions WebViewToolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2026-01-29

### Changed

- Updated README documentation to reflect current sample structure
- Removed references to outdated BasicWebView and UIToolkit Demo samples
- Added comprehensive descriptions for all six current samples (01-06)
- Organized samples by difficulty level with estimated learning times
- Improved documentation clarity and accuracy

## [1.2.0] - 2026-01-29

### Added
Expand Down
104 changes: 76 additions & 28 deletions WebViewToolkit/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WebView Toolkit for Unity - Package Documentation

**Version 1.0.0**
**Version 1.3.0**

Native WebView2 integration for Unity with DirectX 11/12 support. This package provides high-performance, off-screen rendering of modern web content directly to Unity textures.

Expand Down Expand Up @@ -758,7 +758,7 @@ webView.Navigate(fileUrl);

## Samples

The package includes two comprehensive samples demonstrating different integration approaches.
The package includes six progressive samples that teach you WebViewToolkit from beginner to intermediate level.

### Importing Samples

Expand All @@ -767,41 +767,89 @@ The package includes two comprehensive samples demonstrating different integrati
3. Expand the **Samples** section
4. Click **Import** next to the desired sample

### BasicWebView Sample
### Learning Path

**Location:** `Samples~/BasicWebView/`
We recommend completing the samples in order for the best learning experience:

Demonstrates basic WebViewBehaviour usage with traditional Unity UI.
#### 01 - Hello WebView
**Difficulty:** Beginner | **Time:** 5 minutes

Your first WebView! Shows the minimum code needed to display a web page in Unity using UIToolkit.

**What you'll learn:**
- Using WebViewBehaviour component
- Basic navigation controls (Go, Back, Forward, Refresh)
- Handling navigation events
- URL input with Enter key support
- Status display
- Creating a WebViewElement in UXML
- Basic scene setup with UIDocument
- Initial URL configuration

#### 02 - Navigation
**Difficulty:** Beginner | **Time:** 15 minutes

**Key Files:**
- `BasicWebViewSample.cs` - Main sample script
- `BasicWebViewSample.unity` - Demo scene
- `README.md` - Sample-specific instructions
Learn how to navigate between pages, manage history, and respond to navigation events.

### UIToolkit Demo Sample
**What you'll learn:**
- Programmatic navigation with `Navigate()`
- Back/Forward history with `GoBack()`/`GoForward()`
- Checking navigation state with `CanGoBack()`/`CanGoForward()`
- Handling `NavigationCompleted` events
- Enabling/disabling UI based on state

**Location:** `Samples~/UIToolkitDemo/`
#### 03 - JavaScript Bridge
**Difficulty:** Intermediate | **Time:** 30 minutes

Demonstrates WebViewElement and WebViewPanel with UIToolkit.
Master two-way communication between C# and JavaScript. Essential for building interactive web-based UIs.

**What you'll learn:**
- Creating WebViewElement programmatically
- Using WebViewPanel for full browser UI
- Dynamic layout with FlexLayout
- UIToolkit event handling
- Address bar and navigation controls
- Calling JavaScript from C# with `ExecuteScript()`
- Receiving messages from JavaScript via `window.chrome.webview.postMessage()`
- JSON serialization for structured data
- Building game UIs that respond to player actions
- Event-driven communication patterns

#### 04 - Dynamic HTML
**Difficulty:** Intermediate | **Time:** 30 minutes

Generate web content dynamically from C# data. Perfect for inventory systems, quest logs, and leaderboards.

**What you'll learn:**
- Loading HTML strings with `NavigateToString()`
- Building HTML programmatically with C# templates
- Real-time content updates
- Creating data-driven UIs (inventory, quest log, settings)
- HTML templating best practices

#### 05 - Interactive Input
**Difficulty:** Intermediate | **Time:** 20 minutes

Understand how WebView handles mouse and keyboard input, and how to interact with web forms.

**What you'll learn:**
- How WebViewElement forwards mouse events automatically
- Understanding normalized [0-1] coordinate system
- Interacting with web forms (inputs, buttons, checkboxes)
- Mouse hover effects and wheel scrolling
- Debugging input coordinate mapping

#### 06 - Multiple WebViews
**Difficulty:** Intermediate | **Time:** 25 minutes

Learn to manage multiple WebView instances simultaneously for dashboards or split-screen browsers.

**What you'll learn:**
- Creating multiple WebViewElements in one scene
- Proper lifecycle management (creation and disposal)
- Independent navigation for each instance
- Performance considerations and optimization
- Memory management best practices

### Sample Structure

Each sample includes:
- **Unity Scene** - Ready-to-play demo scene
- **C# Scripts** - Thoroughly commented code
- **UXML/USS Files** - UIToolkit layouts and styles
- **README.md** - Detailed walkthrough and explanations

**Key Files:**
- `WebViewUIToolkitDemo.cs` - Main sample script
- `WebViewUIToolkitDemo.unity` - Demo scene
- `README.md` - Sample-specific instructions
For the complete samples overview and additional learning resources, see `Samples~/README.md` after importing.

---

Expand Down Expand Up @@ -1163,6 +1211,6 @@ webView.MessageReceived += (msg) => {

---

**Package Version:** 1.0.0
**Last Updated:** 2026-01-26
**Package Version:** 1.3.0
**Last Updated:** 2026-01-29
**License:** MIT
2 changes: 1 addition & 1 deletion WebViewToolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.webviewtoolkit.core",
"version": "1.2.0",
"version": "1.3.0",
"displayName": "WebView Toolkit",
"description": "Native WebView2 integration for Unity UIToolkit with DirectX 11/12 support. Renders web content to textures for use in Unity UI.",
"unity": "2021.3",
Expand Down