Fix #5811, log error on invalid scene.start(key)

This commit is contained in:
Yuval Greenfield 2021-09-03 23:11:29 -07:00
parent e23d50eb04
commit 1a713b4c5e

View file

@ -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;
},