Files
cocos/tools/unity-level-export.md
刘宇飞 cba5105908 Initial Cocos Creator port of main-site Unity WebGL game.
Includes core gameplay, 600 exported levels, visual assets, web bridge, and bootstrap scene.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 14:57:46 +08:00

983 B
Raw Blame History

Unity 关卡迁移到 Cocos

Unity 原项目约 1.1 万个 Level*.prefabCocos 版使用 JSON/TS 配置 代替 Tilemap Prefab。

配置格式

registerLevel({
  levelID: 601,
  boundary: { x: 20, y: 20 },
  border: { "10,0": true, ... },  // 可选
  ground: { "0,0": "Baseblock", "1,0": "JumpBlock" },  // 可选
  spawns: [
    { x: 0, y: 0, kind: 'player', playerDirection: 0 },
    { x: 3, y: 0, kind: 'prop' },
  ],
});

批量迁移步骤

  1. Assets/Scripts/Core/Levels*.cs 提取 LevelIDspawnsboundary
  2. 若有 Tiled 导出或 Tilemap 脚本,生成 ground / border 稀疏表
  3. 写入 assets/scripts/level/LevelRegistry.ts 或独立 assets/resources/levels/{id}.json
  4. LevelRegistry.tsgetLevelConfig 中合并 JSON 加载

资源迁移

  • 角色/载具贴图:放入 assets/resources/textures/,替换 GameManager.attachVisual 为 Sprite 渲染
  • 音频:放入 assets/resources/audio/