Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: refresh collision layer dropdown when layers change in settings

esengine3d717f44728f
diff --git a/editor/src/property/editors.ts b/editor/src/property/editors.ts
index 5a91ac551..5a963ddce 100644
--- a/editor/src/property/editors.ts
+++ b/editor/src/property/editors.ts
@@ -19,6 +19,7 @@ import { openEntityPicker } from './EntityPicker';
import { setupDragLabel, colorToHex, hexToColor } from './editorUtils';
import { validateNumber, validateVec2, validateVec3, validateColor, showValidationError } from './validation';
import { getNamedLayers, layerIndexFromBits, bitsFromLayerIndex } from '../settings/collisionLayers';
+import { onSettingsChange } from '../settings/SettingsRegistry';
export { setupDragLabel, colorToHex, hexToColor };
// =============================================================================
@@ -2342,6 +2343,14 @@ function createCollisionLayerEditor(
onChange(bitsFromLayerIndex(idx));
});
+ const unsubscribe = onSettingsChange((id) => {
+ if (id.startsWith('physics.layerName')) {
+ const prev = select.value;
+ populateOptions();
+ select.value = prev;
+ }
+ });
+
container.appendChild(select);
return {
@@ -2351,6 +2360,7 @@ function createCollisionLayerEditor(
select.value = String(idx);
},
dispose() {
+ unsubscribe();
select.remove();
},
};