A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(import): a Cocos inactive node becomes the Disabled tag, so its subtree goes with it, instead of a dropped entity that strands its children
yhh0ab5391642c4
diff --git a/pipeline/src/import/cocos/components.ts b/pipeline/src/import/cocos/components.tsindex c33686221..36bb161cd 100644--- a/pipeline/src/import/cocos/components.ts+++ b/pipeline/src/import/cocos/components.ts@@ -251,6 +251,9 @@ export interface ConvertedNode {export function convertNode(node: CocosNode, ctx: ComponentContext, where: string): ConvertedNode {const components: ComponentData[] = [transform(node)];+ // Cocos `active` is switched-off-with-its-subtree, which is what the engine's Disabled tag means; `visible: false`+ // would instead not create the entity at all and leave its children standing on their own.+ if (!node.active) components.push({ type: 'Disabled', data: {} });const box = uiBox(node);const unmapped: Raw[] = [];diff --git a/pipeline/src/import/cocos/convert.ts b/pipeline/src/import/cocos/convert.tsindex 09651bc32..149d2a146 100644--- a/pipeline/src/import/cocos/convert.ts+++ b/pipeline/src/import/cocos/convert.ts@@ -233,7 +233,7 @@ function flatten(tree: XNode, ctx: ConvertContext): Map<string, Flat> {const out = new Map<string, Flat>();const walk = (x: XNode): void => {const conv = convertNode(x.node, ctx, `${ctx.where}: ${x.node.name}`);- out.set(x.addr, { name: x.node.name, visible: x.node.active, components: conv.components });+ out.set(x.addr, { name: x.node.name, visible: true, components: conv.components });x.children.forEach(walk);};walk(tree);@@ -302,7 +302,7 @@ export function convertPrefab(doc: CocosDocument, ctx: ConvertContext): PrefabFiconst walk = (n: CocosNode, parent: string | null): void => {ctx.report.nodes++;const here = `${ctx.where}: ${n.name}`;- const entity: PrefabEntity = { prefabEntityId: n.id, name: n.name, parent, children: [], components: [], visible: n.active };+ const entity: PrefabEntity = { prefabEntityId: n.id, name: n.name, parent, children: [], components: [], visible: true };entities.push(entity);const ref = n.instance ? ctx.prefabRef(n.instance.asset) : null;const overrides = n.instance && ref ? instanceOverrides(n, ctx) : null;@@ -357,7 +357,7 @@ export function convertScene(doc: CocosDocument, ctx: ConvertContext): SceneFileparent: parent ? parent.id : null,children: [],components: conv.components,- visible: n.active,+ visible: true,};if ('metadata' in conv && conv.metadata) entity.metadata = conv.metadata;entities.push(entity);