Skip to content

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.

fix: save current prefab before navigating to nested prefab

esengine306b16e35e7b
diff --git a/editor/src/store/PrefabEditService.ts b/editor/src/store/PrefabEditService.ts
index be0294b9b..404592fac 100644
--- a/editor/src/store/PrefabEditService.ts
+++ b/editor/src/store/PrefabEditService.ts
@@ -242,11 +242,17 @@ export class PrefabEditService {
const prefab = await loadPrefabFromPath(prefabPath);
if (!prefab) return false;
- this.savedSceneState_ = {
- scene: JSON.parse(JSON.stringify(this.host_.state_.scene)),
- filePath: this.host_.state_.filePath,
- isDirty: this.host_.state_.isDirty,
- };
+ if (this.isEditingPrefab) {
+ if (this.host_.state_.isDirty) {
+ await this.trySavePrefabWithRetry();
+ }
+ } else {
+ this.savedSceneState_ = {
+ scene: JSON.parse(JSON.stringify(this.host_.state_.scene)),
+ filePath: this.host_.state_.filePath,
+ isDirty: this.host_.state_.isDirty,
+ };
+ }
if (!isUUID(prefabPath)) {
const uuid = getAssetDatabase().getUuid(prefabPath);