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
feat(editor): Re-import Cocos Project brings the Cocos side's changes into the converted project and keeps the documents edited here; a conversion says which components did not come across
yhhc950b87f815a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 595187d51..ba95f50d4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -21,6 +21,7 @@ published separately; it ships inside the editor.- **More easing curves.** Sine, quart, quint, expo and circ (each in, out and in-out), bounce in and in-out, and smoothstep and smootherstep join the quad, cubic, back, elastic and out-bounce curves. They are new `EasingType` members after the existing ones, so a saved tween keeps its curve, and they ease the same in a C++ tween and a script value tween.- **World content has a rectangle: `ContentRect`.** A size and the pivot the entity's transform sits on, which the `Sprite` and `Text` on the entity follow and which a `UIMask` on it clips to — no `UINode` needed, so a clipping region or a scroll viewport can stand in the world. `contentRectContains` tests a world point against it.- **Open a Cocos Creator project from the editor.** Choosing a Cocos Creator 3.x folder in Open Project (recognised by the Creator version in its `package.json`) offers to convert its scenes and prefabs into a new Estella project beside it, `<name>-estella`, and opens that; the Cocos folder is only read. Opening the same folder again opens the converted project instead of converting twice.+- **Re-import a Cocos project without losing your edits.** Run Re-import Cocos Project in a project converted from Cocos Creator and the scenes and prefabs changed on the Cocos side are brought across, new ones are added, and a document you edited here is left as it is and counted in the result. After the first conversion a message lists the components that did not come across (their data is kept on the entity, but nothing runs), most used first.- **A held pointer reports where it goes, and a hold can be given up.** `pointer_move` goes to the entity a pointer is holding for as long as it is held, `press_cancel` to one whose hold was taken away (`UIControlPointers.cancelHold`, optionally handing the gesture to another entity, so a scroll area can take a drag from the button under it), and every pointer event now says which pointer it was and where, in the world and on the surface. An entity that is only a `ContentRect` with an `Interactable` can be the one pressed.- **The engine's runtime tuning is a project setting.** Project Settings → Game → Runtime sets how a scene switch fades (duration and colour), how far one frame may advance the game and how many fixed steps it may catch up, how long an asset may take to load and how soon a failed one is tried again, how much memory the texture, audio and device-loss caches keep, the text canvas size and the default font family. They were reachable only from code (`RuntimeConfig`) and no project file could carry them. The project holds `features.runtime` with only what differs from the engine's own values (`RUNTIME_BUILD_DEFAULTS`), a build ships the same block, and `initRuntime` applies it before the first asset loads on the web, desktop, native, mini-game and playable targets and in Play. The edit viewport keeps the engine's values.- **Rows for the choices that could only be written into the project file.** Under Rendering: compile shaders in the background, warm them up behind the loading screen and how long to wait, draw only changing frames and how many frames to keep after a change, each level's anti-aliasing (MSAA or temporal; the MSAA count is hidden where temporal ignores it) and its depth pre-pass. Under Game → Display: the render resolution (screen, design resolution or integer multiple). Under the web build: the servers the page may connect to, each checked by the parser the export uses. `check-project-settings` now reads the keys of `QualityConfig`, `QualityProfile` and `RuntimeBuildConfig` and fails a key that has no row and no stated reason, which is how these went unnoticed behind the one row the block had.diff --git a/desktop b/desktopindex dcbf0d3ee..8b0e80578 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit dcbf0d3ee59b837ca66479d4f8e654c91fe70cfe+Subproject commit 8b0e80578b6cf83030842c0a6e3962ddb15d38f9diff --git a/pipeline/src/import/cocos/importProject.ts b/pipeline/src/import/cocos/importProject.tsindex 4f4e8b0cb..4efc659ba 100644--- a/pipeline/src/import/cocos/importProject.ts+++ b/pipeline/src/import/cocos/importProject.ts@@ -8,6 +8,7 @@* keeping the source's folder layout so a path in one is findable in the* other. Only what the converted documents reference is copied.*/+import { createHash } from 'node:crypto';import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';import path from 'node:path';import { isInsideRoot } from '../../fs/pathSandbox';@@ -199,8 +200,31 @@ export function importCocosProject(opts: CocosImportOptions): ImportReportData {}}+ // A converted document is the project's own once it is written: the creator edits it here. A re-import brings the Cocos side's+ // changes into the documents nobody touched, and leaves an edited one alone — the state file holds what was written last.+ const stateFile = path.join(out, 'assets', into, '.import-state.json');+ const written: Record<string, string> = (() => {+ try {+ return (JSON.parse(readFileSync(stateFile, 'utf8')) as { documents?: Record<string, string> }).documents ?? {};+ } catch {+ return {};+ }+ })();+ const digest = (text: string): string => createHash('sha1').update(text).digest('hex');const write = (relPath: string, json: unknown): void => {- if (!opts.dryRun) writeOut(path.join(out, relPath), `${JSON.stringify(json, null, 2)}\n`);+ const text = `${JSON.stringify(json, null, 2)}\n`;+ const file = path.join(out, relPath);+ const next = digest(text);+ const now = existsSync(file) ? digest(readFileSync(file, 'utf8')) : null;+ if (now === null) report.sync.added++;+ else if (now === next) report.sync.unchanged++;+ else if (written[relPath] === now) report.sync.updated++;+ else {+ report.sync.kept.push(relPath);+ return;+ }+ written[relPath] = next;+ if (!opts.dryRun && now !== next) writeOut(file, text);};const byRel = new Map<string, CocosAssetEntry>();@@ -301,6 +325,7 @@ export function importCocosProject(opts: CocosImportOptions): ImportReportData {writeOut(`${dest}.meta`, `${JSON.stringify({ uuid: entry.uuid, version: '2.0', type: 'texture', importer: { sliceBorder: slice } }, null, 2)}\n`);}}+ writeOut(stateFile, `${JSON.stringify({ source, documents: written }, null, 2)}\n`);writeOut(path.join(out, 'assets', into, 'import-report.json'), `${JSON.stringify(report.toJSON(), null, 2)}\n`);}return report.toJSON();diff --git a/pipeline/src/import/cocos/report.ts b/pipeline/src/import/cocos/report.tsindex dc49a8508..fd71de07f 100644--- a/pipeline/src/import/cocos/report.ts+++ b/pipeline/src/import/cocos/report.ts@@ -21,6 +21,8 @@ export interface ImportReportData {components: Record<string, ComponentTally>;notes: Record<string, NoteTally>;assets: { textures: number; missing: string[] };+ /** What a run did to documents already in the project: a document edited since the last run is kept, never overwritten. */+ sync: { added: number; updated: number; unchanged: number; kept: string[] };}const EXAMPLES = 3;@@ -33,6 +35,7 @@ export class ImportReport {private readonly notes = new Map<string, NoteTally>();private readonly missing = new Set<string>();textures = 0;+ readonly sync = { added: 0, updated: 0, unchanged: 0, kept: [] as string[] };component(type: string, status: MapStatus): void {let t = this.components.get(type);@@ -61,6 +64,7 @@ export class ImportReport {components: Object.fromEntries(byCount(this.components, (v) => v.mapped + v.partial + v.unmapped)),notes: Object.fromEntries(byCount(this.notes, (v) => v.count)),assets: { textures: this.textures, missing: [...this.missing].slice(0, 50) },+ sync: this.sync,};}}diff --git a/pipeline/tests/cocos-import.test.ts b/pipeline/tests/cocos-import.test.tsindex 257423d67..3d3d9e72c 100644--- a/pipeline/tests/cocos-import.test.ts+++ b/pipeline/tests/cocos-import.test.ts@@ -275,3 +275,38 @@ describe('importing a Cocos project', () => {expect(problems).toEqual([]);});});++describe('importing again over the same project', () => {+ const ITEM_REL = 'assets/cocos/ui/item.esprefab';+ const stateOf = (): { documents: Record<string, string> } => readJson('assets/cocos/.import-state.json');++ it('finds nothing to do when neither side changed', () => {+ const again = importCocosProject({ source: src, out });+ expect(again.sync.added).toBe(0);+ expect(again.sync.updated).toBe(0);+ expect(again.sync.kept).toEqual([]);+ expect(again.sync.unchanged).toBeGreaterThan(0);+ });++ it('brings the Cocos side\'s change into a document nobody edited', () => {+ // the file as an earlier import wrote it, different from what the source converts to now+ const file = path.join(out, ITEM_REL);+ const stale = `${readFileSync(file, 'utf8').trimEnd()}\n\n`;+ writeFileSync(file, stale);+ const state = stateOf();+ state.documents[ITEM_REL] = createHash('sha1').update(stale).digest('hex');+ writeFileSync(path.join(out, 'assets/cocos/.import-state.json'), JSON.stringify(state));+ const again = importCocosProject({ source: src, out });+ expect(again.sync.updated).toBe(1);+ expect(readFileSync(file, 'utf8')).not.toBe(stale);+ });++ it('keeps a document that was edited here, and says so', () => {+ const file = path.join(out, ITEM_REL);+ const mine = `${JSON.stringify({ ...readJson(ITEM_REL), edited: true }, null, 2)}\n`;+ writeFileSync(file, mine);+ const again = importCocosProject({ source: src, out });+ expect(again.sync.kept).toEqual([ITEM_REL]);+ expect(readFileSync(file, 'utf8')).toBe(mine);+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 92edc9a12..24040999b 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';* the reader recognises anyway.*/export const NOTED = {+ 'feat(editor): Re-import Cocos Project brings the Cocos side's changes into the converted project and keeps the documents edited here; a conversion says which components did not come across':+ {"note":"Re-import a Cocos project without losing your edits."},'feat(editor): opening a Cocos Creator folder converts it into an Estella project beside it and opens that':{"note":"Open a Cocos Creator project from the editor."},'feat(ui): a held pointer reports its moves (pointer_move) and a given-up hold (press_cancel), every pointer event says where the pointer is, and a ContentRect-only entity can be pressed; the Cocos touches translate the engine\'s pointer events instead of dispatching on their own':