Skip to content

doceazedo/godot_wry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WebView Rendering Library for Godot

WRY is a cross-platform webview rendering library. This extension allows you to use the native webview in Godot to build browsers and GUIs with HTML, CSS and JavaScript.

πŸ“₯ Download

You can download the extension directly on the Godot Asset Library or by navigating to the "AssetLib" tab in the editor and searching for "wry".

Alternatively, you can go to the Releases page, download the latest ZIP (not the source code) and import it manually into your project.

βš™οΈ Supported platforms

Platform Support Web engine
Windows βœ… Supported WebView2 (Chromium)
Mac βœ… Supported WebKit
Linux πŸ”„ Work in progress WebKitGTK
Android 🚧 Planned Android WebView (Chromium)
iOS 🚧 Planned WebKit

Windows

Windows 7, 8 and 8.1 are not supported since February 2024 with Rust 1.76, even tho WRY still supports them.

On Windows 10 (Version 1803 and later) and Windows 11, the WebView2 runtime is distributed as part of the operating system.

Needs to be tested.

Linux

WRY depends on WebKitGTK to be installed to work on Linux.

Android/iOS

WRY already offers upstream mobile support. Contributions for implementing support for Android and iOS in this extension are very welcome.

🧰 Getting started

After installing the extension, you will now be able to see the WebView node inside Node β†’ CanvasItem β†’ Control when creating a new node. You can edit it's properties and layout as you wish.

"Create new node" window

WebView inspector

πŸ”„ Interop between WebView and Godot

Godot and the WebView can exchange messages with each other. This is useful for updating the UI data, or triggering game actions when interacting with the UI.

πŸ’‘ Example: you can send a play message on a HTML button click, then Godot can listen for that message and start the game.

Sending messages from Godot to the WebView:

$WebView.post_message("Hello from Godot!")

Sending messages from JavaScript to Godot:

window.ipc.postMessage("Hello from JavaScript!");

Receiving messages in Godot using the ipc_message signal:

func _on_web_view_ipc_message(message):
	print("Just got a message from the webview: %s" % message)

Receiving messages in JavaScript using an event listener:

document.addEventListener("message", (event) => {
  console.log("Just got a message from Godot:");
  console.log(event.detail);
});

πŸ“Œ Other features

  • Load files from res://

🚧 Caveats

Since WRY utilizes the system's native webview for HTML rendering, the results may vary across different platforms, similar to how a website might appear or behave differently in Chrome versus Safari.

It's important to note that WRY renders the webview directly within the window. This prevents rendering on 3D meshes and customizing the rendering process.

If these limitations are significant for your use case, consider alternatives like gdcef or godot-webview.

Godot WRY does not perform dependency checks. As of right now, game developers are responsible for ensuring all dependencies are present and handling missing libraries.

πŸ“ TO-DO

Warning

This extension is in active development, broken stuff is expected and contributions are appreciated!

These features should soon be completed before the 1.0.0 release:

  • React to property changes (such as changing the URL and visibility)
  • Implement JS evaluation
  • Fix transparency when full_window_size is enabled

πŸ“š License

The Godot WRY extension is licensed under MIT. WRY is licensed under Apache-2.0/MIT.