Do you want to work on this issue?
You can request for a bounty in order to promote it!
`Tile.objectGroup = new ObjectGroup()` does not show group in collision editor till different tile is selected #3655
cspotcode posted onGitHub
Describe the bug
When a script programmatically adds a new ObjectGroup()
to a tile, then adds shapes to that tile.objectGroup
, it does not appear in the Collision Editor. It can be made to appear by switching to a different tile, then back to the original tile.
If collision shapes are added in the collision editor before the workaround described above, it seems like the collision editor replaces the scripted objectGroup
with a new one.
It seems like the collision editor UI is not notified about the addition of an objectGroup
via scripting.
To Reproduce
Steps to reproduce the behavior:
Add the following script to a project:
const setupCollisionActionId = 'setup-collision-action';
const setupCollisionAction = tiled.registerAction(setupCollisionActionId, (a) => {
const tileset = tiled.activeAsset;
if(tileset.isTileset) {
const tileset = tiled.activeAsset;
const [tile] = tileset.selectedTiles;
if(tile.objectGroup == null) {
tile.objectGroup = new ObjectGroup();
}
const point = new MapObject('origin');
point.shape = MapObject.Point;
tile.objectGroup.addObject(point);
}
});
setupCollisionAction.text = "Setup Collision";
tiled.extendMenu('TilesetView.Tiles', [{
action: 'setup-collision-action'
}]);
Open a tileset with at least two tiles, that do not have any collision shapes in the collision editor.
Select the first tile.
Open the collision editor before the next step.
Right-click the tile, click "Setup Collision" to run the scripted action.
Observe that the collision editor does not show the new Point
Click the second tile in the tileset, then click back to the first.
Observe that the collision editor is now showing the new Point
Expected behavior
When scripting adds an objectGroup
to a tile, it should appear immediately in the collision editor.
Media
Specifications:
- OS: Windows 11
- Tiled Version: 1.10.1