I have been able to load a plugin into a scene this way:
class Ranking extends Phaser.Scene {
constructor() {
super({
key: 'ranking'
});
}
preload() {
this.load.scenePlugin({
key: 'rexuiplugin',
url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js',
sceneKey: 'rexUI'
});
}
}
Then, found this example which loads a plugin globally in the game config
:
const config = {
type: Phaser.AUTO,
parent: 'phaser-example',
width: 800,
height: 600,
plugins: {
global: [
{ key: 'RandomNamePlugin', plugin: RandomNamePlugin, start: true }
]
},
scene: {
preload: preload,
create: create
}
};
let game = new Phaser.Game(config);
My question is: is it possible to add a plugin globally but using an URL (like in the this.load.scenePlugin()
shown above) instead of directly the JavaScript class? So, I would have something like this:
...
plugins: {
global: [
{ key: 'rexuiplugin', url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js',start: true }
]
},
...
If I try this last way, and try to use it in some scene, I get null
when I try this.plugins.get('rexuiplugin')
in the preload()
method.