Skip to content

feat(scene): add node serialization and batch restoration - #934

Open
YuchenWell wants to merge 4 commits into
cocos:mainfrom
YuchenWell:0.1.37/feat/cross-scene-node-copy-paste
Open

feat(scene): add node serialization and batch restoration#934
YuchenWell wants to merge 4 commits into
cocos:mainfrom
YuchenWell:0.1.37/feat/cross-scene-node-copy-paste

Conversation

@YuchenWell

@YuchenWell YuchenWell commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Background

Provide the cocos-cli foundation for cross-scene node copying by exporting selected node hierarchies as transferable data and restoring them in a target scene.

Changes

  • Add Node.serialize and Node.createBySerializedData, serializing all selected roots together to preserve internal node and component references
  • Reuse existing serialization and engine deserialization, with valueReplacer handling parent links, prefab metadata, and external references without modifying source nodes
  • Support insertion position, world-transform preservation, and external-reference clearing or resolution
  • Generate fresh identities for copies and preserve snapshot identities during Redo
  • Record batch creation as one undo operation and roll back nodes and parent prefab metadata if mounting or snapshot capture fails

Scope

  • Update Scene services, process proxies, and public type snapshots
  • Add coverage for rollback, prefab handling, reference restoration, and Undo/Redo
  • PinK clipboard and copy/paste UI integration will follow separately

Test Plan

  • Serialize mutually referencing nodes in scene A, then restore them in scene B; internal references should point to the new nodes, while external references are cleared by default
  • Restore a complete prefab instance and a separately copied child; the complete instance should retain its association, while the child should detach from the original instance
  • Undo and redo batch creation; all roots and their internal references should be removed and restored together
  • Inject mounting or snapshot failures; no nodes from the failed batch should remain in the target scene

@YuchenWell YuchenWell closed this Sep 10, 2026
@YuchenWell YuchenWell reopened this Sep 10, 2026
- Add Node.serialize and Node.createBySerializedData APIs
- Preserve internal references and handle prefab and external references
- Support atomic batch creation and grouped Undo/Redo
- Update public types and add rollback and real-engine tests
@YuchenWell
YuchenWell force-pushed the 0.1.37/feat/cross-scene-node-copy-paste branch from c29127f to 8b6a2e1 Compare September 10, 2026 03:36
@YuchenWell YuchenWell changed the title feat(scene): support node serialization and atomic batch creation feat(scene): add node serialization and batch restoration Sep 10, 2026
@YuchenWell YuchenWell closed this Sep 10, 2026
@YuchenWell YuchenWell reopened this Sep 10, 2026
@YuchenWell
YuchenWell force-pushed the 0.1.37/feat/cross-scene-node-copy-paste branch from c7f59a0 to b5e271e Compare September 10, 2026 06:31
@YuchenWell YuchenWell closed this Sep 10, 2026
@YuchenWell YuchenWell reopened this Sep 10, 2026
@YuchenWell
YuchenWell marked this pull request as ready for review September 10, 2026 08:24
@wuzhiming
wuzhiming requested a review from knoxHuang September 10, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant