From 049607d9fa403a024bdf9b925d0367c5f0ef68ca Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Mon, 17 Dec 2018 19:32:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=9C=BA=E6=99=AF=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E9=80=89=E4=B8=AD=E7=8A=B6=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/src/editor/bottom/ScenePanel.js | 9 +++++++++ ShadowEditor.Web/src/editor/menubar/SceneMenu.js | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/ShadowEditor.Web/src/editor/bottom/ScenePanel.js b/ShadowEditor.Web/src/editor/bottom/ScenePanel.js index 6e398fe8..2d963576 100644 --- a/ShadowEditor.Web/src/editor/bottom/ScenePanel.js +++ b/ShadowEditor.Web/src/editor/bottom/ScenePanel.js @@ -338,6 +338,15 @@ ScenePanel.prototype.onLoadScene = function (obj) { this.app.editor.camera.updateProjectionMatrix(); + if (obj.options.selected) { + var obj = this.app.editor.objectByUuid(obj.options.selected); + if (obj) { + this.app.editor.select(obj); + } else { + console.warn(`ScenePanel: 无法选中uuid为${obj.options.selected}的物体!`); + } + } + this.app.call('sceneLoaded', this); }; diff --git a/ShadowEditor.Web/src/editor/menubar/SceneMenu.js b/ShadowEditor.Web/src/editor/menubar/SceneMenu.js index fb65c513..672fdee4 100644 --- a/ShadowEditor.Web/src/editor/menubar/SceneMenu.js +++ b/ShadowEditor.Web/src/editor/menubar/SceneMenu.js @@ -95,6 +95,12 @@ SceneMenu.prototype.saveScene = function () { // 保存场景 SceneMenu.prototype.commitSave = function (sceneName) { var editor = this.app.editor; + // 记录选中物体,以便载入时还原场景选中 + var selected = this.app.editor.selected; + if (selected) { + this.app.options.selected = selected.uuid; + } + var obj = (new Converter()).toJSON({ options: this.app.options, camera: editor.camera,