[英]I am trying to make scoring function for my game in spark ar, but promise.all doesn't seems to work
我对编程很陌生,我正在尝试使用脚本来修补桥接技术。 我不知道为什么这不起作用,这是我的代码:
const Scene = require('Scene');
const Patches = require('Patches');
export const Diagnostics = require('Diagnostics');
const patchValue = Patches.getScalarValue('GameScore');
Promise.all([
Scene.root.findFirst("sampletxt"),
]).then(function(results){
var ScoreText = results[0];
ScoreText.text = patchValue.toString();
});
Diagnostics.watch('runtime -', patchValue); // im using this line to see if the script reads the value from patch.
这是控制台日志中的错误:
请改用PatchesModule.outputs.getScalar
! @爱马仕运行时
此 API 已弃用,请升级到最新的 SDK 版本。 信息:
@
HermesRuntime
Possible Unhandled Promise Rejection: Unexpeted SceneObject reference: {"identifier":"2_d_text_model:7030-1be1a0e4-3bb6-4a3b-bc9c-e17b7b57aa6c","name":"sampletxt","materialIdentifier":"","className":"planarText","modelId":505}
请帮帮我,谢谢
const Patches = require("Patches");
//onStart Set GameScore Value
Patches.outputs.getScalar("GameScore").then((event) => {
var ScoreText = event.pinLastValue();
Patches.inputs.setString("outputScore", ScoreText.toString());
//onChange Update GameScore Value
event.monitor().subscribe(function (values) {
ScoreText = values.newValue;
Patches.inputs.setString("outputScore", ScoreText.toString());
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.