Skip to content

Commit 9f7d3bf

Browse files
committed
Allowed get to return the class and added autoStart boolean
1 parent 5e667ec commit 9f7d3bf

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/plugins/PluginManager.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,14 @@ var PluginManager = new Class({
573573
* @since 3.8.0
574574
*
575575
* @param {string} key - The key of the plugin to get.
576+
* @param {boolean} [autoStart=true] - Automatically start a new instance of the plugin if found in the cache, but not actively running.
576577
*
577-
* @return {?Phaser.Plugins.BasePlugin} The plugin, or `null` if no plugin was found matching the key.
578+
* @return {?(Phaser.Plugins.BasePlugin|function)} The plugin, or `null` if no plugin was found matching the key.
578579
*/
579-
get: function (key)
580+
get: function (key, autoStart)
580581
{
582+
if (autoStart === undefined) { autoStart = true; }
583+
581584
var entry = this.getEntry(key);
582585

583586
if (entry)
@@ -588,7 +591,7 @@ var PluginManager = new Class({
588591
{
589592
var plugin = this.getClass(key);
590593

591-
if (plugin)
594+
if (plugin && autoStart)
592595
{
593596
var instance = new plugin(this);
594597

@@ -605,6 +608,10 @@ var PluginManager = new Class({
605608

606609
return instance;
607610
}
611+
else if (plugin)
612+
{
613+
return plugin;
614+
}
608615
}
609616

610617
return null;

0 commit comments

Comments
 (0)