Skip to content

Commit 7dddb38

Browse files
Julien Moreau-Mathisjulien-moreau
authored andcommitted
fix: update relative path for textures applied on attached scripts
#507
1 parent 177c02f commit 7dddb38

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

editor/src/editor/layout/assets-browser.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,32 @@ export class EditorAssetsBrowser extends Component<IEditorAssetsBrowserProps, IE
439439
});
440440
});
441441

442-
// TODO: Scripts
442+
// Scripts
443+
const nodes = [scene, ...scene.transformNodes, ...scene.meshes, ...scene.lights, ...scene.cameras];
444+
const scripts = nodes.map((node) => node.metadata?.scripts ?? []).flat();
445+
446+
scripts.forEach((script) => {
447+
for (const v in script.values) {
448+
if (!script.values.hasOwnProperty(v)) {
449+
continue;
450+
}
451+
452+
const value = script.values[v];
453+
if (!value.value) {
454+
continue;
455+
}
456+
457+
if (value.type === "texture") {
458+
const serializationObject = value.value;
459+
if (serializationObject?.name === oldRelativePath) {
460+
serializationObject.name = newRelativePath;
461+
if (serializationObject.url) {
462+
serializationObject.url = newRelativePath;
463+
}
464+
}
465+
}
466+
}
467+
});
443468
}
444469

445470
/**

0 commit comments

Comments
 (0)