fix(scripts): emitPrefabJson rootNode._children 必须包含 group-X 节点 (Task 9 fix round 1)
This commit is contained in:
@@ -29,3 +29,16 @@ test('Layer00619 端到端生成 + 校验关键字段', () => {
|
||||
const groupNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'group-55');
|
||||
assert.ok(groupNode, '应有 group-55 父节点');
|
||||
});
|
||||
|
||||
test('Layer00619 端到端 - root._children 包含 group-55', () => {
|
||||
execSync(`${CLI} ${INPUT} ${TARGET} ${OUTPUT_DIR}`, { stdio: 'pipe' });
|
||||
const json = JSON.parse(readFileSync(OUTPUT, 'utf8'));
|
||||
const rootNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'BackHall_Layer');
|
||||
const groupNode = json.find(o => o.__type__ === 'cc.Node' && o._name === 'group-55');
|
||||
assert.ok(rootNode, '应有 root node');
|
||||
assert.ok(groupNode, '应有 group-55 node');
|
||||
// The fix: root._children must reference group-55
|
||||
const childIds = (rootNode._children || []).map(c => c.__id__);
|
||||
assert.ok(childIds.includes(json.indexOf(groupNode)),
|
||||
`root._children must include group-55 reference; got [${childIds.join(', ')}]`);
|
||||
});
|
||||
@@ -614,7 +614,9 @@ export function emitPrefabJson(layer) {
|
||||
for (const g of groupParents) {
|
||||
const node = makeNode(g.name, { __id__: rootId });
|
||||
out.push(node);
|
||||
groupInfo.push({ group: g, node, nodeId: out.length - 1 });
|
||||
const nodeId = out.length - 1;
|
||||
rootNode._children.push({ __id__: nodeId }); // wire group node into root._children (Task 9 fix round 1)
|
||||
groupInfo.push({ group: g, node, nodeId });
|
||||
}
|
||||
|
||||
// ── 4. Spirit 子节点 + 组件 ────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user