手冊:HTML-based UI/Core

出自Minecraft基岩版开发Wiki

Core 包是 HbUI 已開放的核心介面包,其中包含的子包如下:

scripting[編輯]

core.scripting 介面用於與腳本進行對接。

屬性[編輯]

方法[編輯]

triggerEvent (Data)[編輯]

參數[編輯]
名稱 型別 描述
Data 字串 此字串將會被傳送至本地腳本的 "minecraft:ui_event" 事件
範例[編輯]

向本地腳本端傳送 "SendThisDataToTheScript" 字串

let scriptInterface = undefined;
engine.on("facet:updated:scripting", function(interface) {
  scriptInterface = interface;
});
engine.trigger("facet:request", ["scripting"]);
scriptInterface.triggerEvent("SendThisDataToTheScript");

locale[編輯]

core.locale 介面用於取得附加包中已載入的在地化文字以及格式化時間文字。

屬性[編輯]

locale[編輯]

目前的語言地區程式碼(如:zh_CN

方法[編輯]

translate(LocaleTextKey)[編輯]

參數[編輯]
名稱 型別 描述
LocaleTextKey 字串 需要被轉換的在地化鍵名
傳回值[編輯]

傳回傳入的在地化鍵名對應遊戲目前所設定語言的文字。

範例[編輯]

取得鍵名為 "ui.test.hello_world"在目前語言下所對應的文字

translateWithParameters[編輯]

formatDate[編輯]

sound[編輯]

user[編輯]

deviceInformation[編輯]

safeZone[編輯]

splitScreen[編輯]

featureFlags[編輯]

input[編輯]

router[編輯]

screenReader[編輯]

animation[編輯]