Skip to content

Commit f189884

Browse files
committed
fix: throw error when no script exported values in babylonjs-editor-tools
1 parent 025bc26 commit f189884

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

tools/src/decorators/apply.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,14 @@ export function applyDecorators(scene: Scene, object: any, script: any, instance
159159
});
160160

161161
// @visibleAsNumber, @visibleAsBoolean etc.
162-
(ctor._VisibleInInspector ?? []).map(async (params) => {
162+
(ctor._VisibleInInspector ?? []).forEach(async (params) => {
163163
const propertyKey = params.propertyKey.toString();
164164
const attachedScripts = script.values;
165165

166+
if (!attachedScripts) {
167+
throw new Error(`No values found for script with key "${script.key}".`);
168+
}
169+
166170
if (attachedScripts.hasOwnProperty(propertyKey) && attachedScripts[propertyKey].hasOwnProperty("value")) {
167171
const value = attachedScripts[propertyKey].value;
168172

tools/src/loading/script.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export async function _preloadScriptsAssets(scene: Scene, rootUrl: string) {
3030
.flat();
3131

3232
scripts.forEach((script) => {
33+
if (!script.values) {
34+
return;
35+
}
36+
3337
for (const key in script.values) {
3438
if (!script.values.hasOwnProperty(key)) {
3539
continue;

0 commit comments

Comments
 (0)