Skip to content

Add preview logic#479

Merged
star-e merged 9 commits intococos:main-previewfrom
bofeng-song:main-preview
Apr 14, 2026
Merged

Add preview logic#479
star-e merged 9 commits intococos:main-previewfrom
bofeng-song:main-preview

Conversation

@bofeng-song
Copy link
Copy Markdown
Contributor

No description provided.

(cherry picked from commit 9ef6e32)
(cherry picked from commit 0a10b9ae96d115852c5aa506790bbe2f47cde221)
@bofeng-song bofeng-song requested a review from knoxHuang April 13, 2026 06:30
}



Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空格太多

await EditorExtends.init();
}

// await (globalThis as any).System.import('cc');
Copy link
Copy Markdown
Contributor

@knoxHuang knoxHuang Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要的代码删了吧


// 切换物理引擎
cc.physics.selector.switchTo(backend);
cc.view.setDesignResolutionSize(1920, 1080, cc.ResolutionPolicy.SHOW_ALL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不能写死,后续可能要读配置,可以写个 TODO 吧

cc.game.pause();
const json = startScene;
// load scene
cc.assetManager.loadWithJson(json, { assetId: json[1]._id },
Copy link
Copy Markdown
Contributor

@knoxHuang knoxHuang Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最好初始化跟加载场景区分开来,后续可能先初始化 webview,加快场景打开的速度

}

async getDefaultConfig(serverURL: string, importBase: string, nativeBase: string) {
async getPreviewConfig(serverURL: string, importBase: string, nativeBase: string) {
Copy link
Copy Markdown
Contributor

@knoxHuang knoxHuang Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果这个是共用的,就不要写 PreviewConfig,叫 getSettingConfig ?否则也容易误导

Copy link
Copy Markdown
Contributor

@knoxHuang knoxHuang Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果这个是通用的,就改个名字吧,不要 preview,否则可能容易误导

<canvas id="GameCanvas" tabindex="-1" style="background-color: '';"></canvas>
</div>
</div>
<!-- <canvas id="GameCanvas" oncontextmenu="event.preventDefault()" tabindex="0"></canvas> -->
Copy link
Copy Markdown
Contributor

@knoxHuang knoxHuang Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要的就删了吧

@@ -73,19 +78,20 @@
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个最好是一个入口函数,需要 pink 那边加载,否则要写 2 边

// closure matches its register. One System = no bridging needed.
globalThis.System = _originalSystem;

const sceneListPromise = await fetch(`${currentUrl}/query-asset-infos/cc.SceneAsset`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你这里其实需要做的,只需要做到初始化引擎 + 初始化场景流程就行,不需要去主动加载场景,加载场景是外部调用 打开 API 触发的

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是cli端,用来测试用的

@star-e star-e merged commit 83c7faa into cocos:main-preview Apr 14, 2026
0 of 2 checks passed
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.

3 participants