It hasn't been long since the last Web progress report, but it's finally time for the blog entry you have probably been waiting for... time to talk ab

Godot Web progress report #9: Godot Scripts <-> JavaScript Interface

submited by
Style Pass
2021-06-30 17:00:10

It hasn't been long since the last Web progress report, but it's finally time for the blog entry you have probably been waiting for... time to talk about integrating Godot with third-party JavaScript APIs on the Web.

Sometimes, when exporting Godot for the Web, it might be necessary to interface with external JavaScript code. Things like third-party SDKs, libraries, or simply accessing browser features that are not directly exposed by Godot.

Historically, this has been done in Godot via the JavaScript.eval method. This relied on the JavaScript eval() function, which beside being dangerous when misused, is also quite cumbersome to use.

For these reasons, a new interface has been developed. This new interface feels more natural in the context of Godot scripting (e.g. GDScript and C#).

A new JavaScriptObject class has been added that wraps around native JavaScript objects and allows to call JavaScript methods and retrieve object properties.

Leave a Comment