Global plugins are properly registered to scenes when the game is hot-reloaded
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- game-dev
Línea de trabajo
Comienza con src/plugins/PluginManager.js en las líneas enlazadas 444-448 y, a continuación, reproduce el problema utilizando la configuración global de plugins y el acceso a la escena mostrado en el informe. Comprueba la ruta de hot-reload y confirma que la recarga ya no produce “Plugin key in use: l10n” y que el mapeo de la escena sigue disponible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
- Phaser Version: 3.88.2
- Operating system: Windows
- Browser: Chrome
Description
When adding a global plugin through the game config, the plugin is automatically added to scenes.
However, if you're using hot-reloading (by default, I'm using the Svelte game template, which has this), re-adding the plugin doesn't work (Plugin key in use) as it's already there.
Because of this, however, re-registering with scenes doesn't work, and you need to do it manually in the Boot scene or whatever
init() {
const localisation = this.game.plugins.get(localisationPluginMapping) as LocalisationPlugin;
this.game.scene.getScenes(false).forEach((scene) => {
scene.l10n = localisation;
});
}
I think it's because of this code in PluginManager.js where it returns null instead of the plugin.
Example Test Code
Create a basic plugin:
export class LocalisationPlugin extends Phaser.Plugins.BasePlugin {
constructor(pluginManager: Phaser.Plugins.PluginManager) {
super(pluginManager);
}
...
}
export const LocalisationPluginConfig: Phaser.Types.Core.PluginObjectItem = {
key: 'l10n',
plugin: LocalisationPlugin,
mapping: 'l10n'
};
Add the plugin to your config
const config: Phaser.Types.Core.GameConfig = {
type: AUTO,
width: Math.min(1024, window.innerWidth),
height: Math.min(768, window.innerHeight),
parent: 'game-container',
backgroundColor: '#028af8',
scene: [Boot, Preloader, MainMenu, MainGame],
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH
},
plugins: {
global: [LocalisationPluginConfig]
}
};
In one of your scenes, access the plugin
create() {
this.instructionsText = this.add
.text(
this.cameras.main.width / 2,
this.cameras.main.height - 100,
this.l10n.translateClickToStart().toUpperCase(),
{
fontFamily: 'Arial',
fontSize: 15,
color: '#ffffff',
stroke: '#000000',
strokeThickness: 3,
align: 'center'
}
)
.setOrigin(0.5);
}
Perform some action where hot-reloading is necessary. You should see the warning message Plugin key in use: l10n and the call to translateClickToStart will fail as l10n is undefined
Additional Information
I have very little experience with the code, but I think we could either:
- Properly remove global plugins (scene plugins may also suffer, I haven't tested) so they can be re-added as normal
- Gracefully handle the plugin already existing so it can still be re-registered with scenes (return the plugin rather than
null) - Use
this.game.plugins.get('l10n')rather than the return of registering the plugin (which is what I'm assuming it's using)
- Lenguaje dominante
- JavaScript
- Estrellas
- 40.7k
- Forks
- 7.2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de phaserjs/phaser
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Los mantenedores suelen responder en 3 días
-
Type definition for TilemapLayer.getTileAt is wrongPosiblemente ocupada @hkbughk la tomó hace 34 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 3 días
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Posiblemente ocupada @k1epg01ng129-eng la tomó hace 32 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 3 días
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGLPosiblemente ocupada @SamuelMalmfors la tomó hace 14 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
phaserjs/phaser#7392 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Todos los issues de phaserjs/phaser
Issues similares
-
enhancement ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
DCGM/semant-demo#708 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
agents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the modulePosiblemente ocupada @MalithaPrabhashana la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
jaseci-labs/jac#10756 ·
Los mantenedores suelen responder en 1 día