Scripting API
Scripting API
JSImportAttribute
Class in Abyss.Core, from Abyss.Core.
Marks a static partial method whose body the engine writes: in a game playing in a browser it calls the function of the same name, camel-cased, that the game's web/<Class>.js exports — Ads.ShowRewarded calls showRewarded in web/Ads.js — and in the editor and a desktop build the same method of its class's stand-in (JSStandInAttribute).
public sealed class JSImportAttribute : AttributeRemarks
What crosses: bool, numbers, string, enums as their names camel-cased, classes, records and structs as plain objects of their public members, camel-cased, arrays and lists, and null. A long beyond 2^53 loses its last digits, as every number in JavaScript.
A promise is a Task: a method returning Task<TResult> waits for what the function's promise gives, and goes on on the engine thread at the start of a frame, as the rest of a game's async code does. One returning a value takes the function's at once; a promise it is given fails it.
What the page throws arrives as a JSException with its message. The build warns of a method whose function its script does not export (ABYSS035).
