Merge pull request #5825 from ubershmekel/master

Fix #5811, log error on invalid scene.start(key)
This commit is contained in:
Richard Davey 2021-09-20 11:54:49 +01:00 committed by GitHub
commit 9adcd5c615
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1151,54 +1151,57 @@ var SceneManager = new Class({
var scene = this.getScene(key); var scene = this.getScene(key);
if (scene) if (!scene)
{ {
var sys = scene.sys; console.warn('Scene not found for key: ' + key);
return this;
// 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);
} }
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; return this;
}, },