From 1a713b4c5ecc1d9d4c49c0f645ea27be43b9f2d4 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Fri, 3 Sep 2021 23:11:29 -0700 Subject: [PATCH] Fix #5811, log error on invalid scene.start(key) --- src/scene/SceneManager.js | 93 ++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 78bf26d7f..bbc3d862b 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -1151,54 +1151,57 @@ var SceneManager = new Class({ var scene = this.getScene(key); - if (scene) + if (!scene) { - var sys = scene.sys; - - // If the Scene is already running (perhaps they called start from a launched sub-Scene?) - // then we close it down before starting it again. - if (sys.isActive() || sys.isPaused()) - { - sys.shutdown(); - - sys.sceneUpdate = NOOP; - - sys.start(data); - } - else - { - sys.sceneUpdate = NOOP; - - sys.start(data); - - var loader; - - if (sys.load) - { - loader = sys.load; - } - - // Files payload? - if (loader && sys.settings.hasOwnProperty('pack')) - { - loader.reset(); - - if (loader.addPack({ payload: sys.settings.pack })) - { - sys.settings.status = CONST.LOADING; - - loader.once(LoaderEvents.COMPLETE, this.payloadComplete, this); - - loader.start(); - - return this; - } - } - } - - this.bootScene(scene); + console.warn('Scene not found for key: ' + key); + return this; } + var sys = scene.sys; + + // If the Scene is already running (perhaps they called start from a launched sub-Scene?) + // then we close it down before starting it again. + if (sys.isActive() || sys.isPaused()) + { + sys.shutdown(); + + sys.sceneUpdate = NOOP; + + sys.start(data); + } + else + { + sys.sceneUpdate = NOOP; + + sys.start(data); + + var loader; + + if (sys.load) + { + loader = sys.load; + } + + // Files payload? + if (loader && sys.settings.hasOwnProperty('pack')) + { + loader.reset(); + + if (loader.addPack({ payload: sys.settings.pack })) + { + sys.settings.status = CONST.LOADING; + + loader.once(LoaderEvents.COMPLETE, this.payloadComplete, this); + + loader.start(); + + return this; + } + } + } + + this.bootScene(scene); + return this; },