From 73629cf4d0e53aea97973ad501749f71b2e0b0a6 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Tue, 1 Jul 2025 14:35:39 +0100 Subject: [PATCH] Fix attribute retrieval in ScriptComponent for improved compatibility with new data structures --- src/framework/components/script/component.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/framework/components/script/component.js b/src/framework/components/script/component.js index c13e8c50455..78952c89822 100644 --- a/src/framework/components/script/component.js +++ b/src/framework/components/script/component.js @@ -969,7 +969,7 @@ class ScriptComponent extends Component { // otherwise it means that the attributes have already been initialized // so convert the new guid to an entity // and put it in the new attributes - const newAttributesRaw = newScriptComponent[scriptName].__attributesRaw; + const newAttributesRaw = newScriptComponent[scriptName].__attributesRaw ?? newScriptComponent._attributeDataMap.get(scriptName); const newAttributes = newScriptComponent[scriptName].__attributes; if (!newAttributesRaw && !newAttributes) { continue; @@ -979,14 +979,15 @@ class ScriptComponent extends Component { const useGuid = !!newAttributesRaw; // get the old script attributes from the instance - const oldAttributes = script.instance.__attributes; + const oldAttributes = script.instance.__attributes ?? newScriptComponent._attributeDataMap.get(scriptName); for (const attributeName in oldAttributes) { if (!oldAttributes[attributeName]) { continue; } // get the attribute definition from the script type - const attribute = scriptType.attributes.get(attributeName); + const attribute = scriptType.attributes?.get(attributeName) ?? + this.system.app.scripts.getSchema(scriptName)?.attributes?.[attributeName]; if (!attribute) { continue; }