Should I just register all my scene plugins (via config) and have them available to all scenes? (ie, thinking of them as global extensions, with functionality that is explicitly invoked where needed)
Or conversely, trying to only load plugins for scenes that actually need them? (thinking of them more as composable elements, that may provide implicit/automatic functionality just by being attached to a scene)
It seems like the former is what I see used in practice in examples and discussions.
I’ll give you an example: Trying to build an RPG with an overworld, towns, caves, etc. These are all “locations” (a scene that a player can walk around in), so I’m trying to put that functionality into a Location scene plugin.
Should I be trying to only load this plugin for those scenes, or register it for all scenes (and then only initialize it from the scenes that want to use it)?
I find the examples that load scene plugins kinda weird (eg Phaser - Examples - v3.85.0 - plugins - Load Scene Plugin Test 1), is loading at runtime via a URL (in assets) really the way to go? I would much prefer to import them.
I have found that this seems to work, even though I can find no documentation or examples that use this approach:
import MyScenePlugin from './MyScenePlugin';
export default class MyScene extends Phaser.Scene {
preload() {
this.load.scenePlugin('myScenePlugin', MyScenePlugin);
}
}
Thanks in advance for any help or guidance!