Global plugins are properly registered to scenes when the game is hot-reloaded
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- game-dev
Direzione di ricerca
Inizia da src/plugins/PluginManager.js alle righe collegate 444-448, quindi riproduci il problema utilizzando la configurazione globale dei plugin e l’accesso alla scena mostrati nel report. Controlla il percorso di hot-reload e conferma che il ricaricamento non produca più “Plugin key in use: l10n” e che la mappatura della scena rimanga disponibile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- JavaScript
- Stelle
- 40.7k
- Fork
- 7.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di phaserjs/phaser
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 3 giorni
-
Type definition for TilemapLayer.getTileAt is wrongForse già presa @hkbughk l’ha presa 34 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 3 giorni
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Forse già presa @k1epg01ng129-eng l’ha presa 32 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 3 giorni
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGLForse già presa @SamuelMalmfors l’ha presa 14 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
phaserjs/phaser#7392 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di phaserjs/phaser
Issue simili
-
enhancement ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
DCGM/semant-demo#708 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 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
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the moduleForse già presa @MalithaPrabhashana l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
jaseci-labs/jac#10756 ·
I maintainer di solito rispondono entro 1 giorno