Global plugins are properly registered to scenes when the game is hot-reloaded
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- game-dev
調査の方向性
まず、リンク先の444-448行目にあるsrc/plugins/PluginManager.jsから始め、次に、レポートに示されているグローバルプラグイン設定とシーンへのアクセスを使って問題を再現します。hot-reloadの経路を確認し、再読み込みによって「Plugin key in use: l10n」が発生しなくなり、シーンのマッピングが引き続き利用可能であることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- JavaScript
- スター
- 40.7k
- フォーク
- 7.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
phaserjs/phaser のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
Type definition for TilemapLayer.getTileAt is wrong対応中かも @hkbughk が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 3 日以内に返信
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)対応中かも @k1epg01ng129-eng が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 3 日以内に返信
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGL対応中かも @SamuelMalmfors が 14 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
phaserjs/phaser#7392 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
phaserjs/phaser の issue をすべて見る
似ている issue
-
enhancement ready
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DCGM/semant-demo#708 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 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
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the module対応中かも @MalithaPrabhashana が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
jaseci-labs/jac#10756 ·
メンテナーはふだん 1 日以内に返信