Global plugins are properly registered to scenes when the game is hot-reloaded
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- game-dev
Hướng nghiên cứu
Bắt đầu với src/plugins/PluginManager.js tại các dòng được liên kết 444-448, sau đó tái hiện sự cố bằng cấu hình plugin toàn cục và quyền truy cập scene được nêu trong báo cáo. Kiểm tra đường dẫn hot-reload và xác nhận rằng việc tải lại không còn tạo ra “Plugin key in use: l10n” và ánh xạ scene vẫn khả dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- JavaScript
- Star
- 40.7k
- Fork
- 7.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của phaserjs/phaser
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Type definition for TilemapLayer.getTileAt is wrongCó thể đã có người làm @hkbughk đã nhận 34 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Có thể đã có người làm @k1epg01ng129-eng đã nhận 32 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGLCó thể đã có người làm @SamuelMalmfors đã nhận 14 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
phaserjs/phaser#7392 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của phaserjs/phaser
Issue tương tự
-
enhancement ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DCGM/semant-demo#708 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 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
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the moduleCó thể đã có người làm @MalithaPrabhashana đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
jaseci-labs/jac#10756 ·
Maintainer thường phản hồi trong vòng 1 ngày