You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When removing (but not freeing!) a TileMap from the tree, any of its child nodes that were SceneCollection tiles are freed! Then when the TileMap is re-added, they are re-instantiated from their scene file.
It should be possible to remove/re-add a TileMap from the tree without it deleting and re-instantiating all of its child Scene tiles. This erases all the state that might have set on those tiles since instantiation! This does not seem like correct or useful behavior based on how add_child and remove_child work everywhere else.
Some other notes:
The TileMap's non-SceneTile children are not freed in this way, which is why I expected that its SceneTile children should receive the same treatment.
Reparent the SceneTile somewhere else causes it to not be freed upon removal of the TileMap
Steps to reproduce
I have a minimal repro project here (also attached) that shows scene tiles being deleted/re-instantiated and their state being erased.
Run the project
Click on a tile (the white circles) to turn it red
Sounds like something that should've been fixed by #67330
There were multiple other bugfixes to scene tiles, so the bug might've resurfaced. This still happens with TileMapLayers in 4.3.
I'm trying to figure out what the right solution is, and I'm realizing a parallel issue exists with the child nodes' creation. Scene Tile child nodes are only instantiated when the TileMap first enters the tree, rather than when the TileMap is instantiated.
It seems like maybe these Scene Tile child nodes' lifetimes should be tied to the TileMap's init/free rather than its enter_tree/exit_tree. Does that make sense?
This behavior is intended. Scene Tiles are not really expected to behave like regular nodes the tree, and their lifetime is the TileMap's to manage. To get this functionality, make regular Nodes in the tree and parent them to the TileMap.
Not going to fix this issue. #92189 (comment)
Tested versions
System information
Godot v4.2.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1080 () - Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz (8 Threads)
Issue description
When removing (but not freeing!) a TileMap from the tree, any of its child nodes that were SceneCollection tiles are freed! Then when the TileMap is re-added, they are re-instantiated from their scene file.
It should be possible to remove/re-add a TileMap from the tree without it deleting and re-instantiating all of its child Scene tiles. This erases all the state that might have set on those tiles since instantiation! This does not seem like correct or useful behavior based on how add_child and remove_child work everywhere else.
Some other notes:
Steps to reproduce
I have a minimal repro project here (also attached) that shows scene tiles being deleted/re-instantiated and their state being erased.
Minimal reproduction project (MRP)
SceneCollectionBug.zip
The text was updated successfully, but these errors were encountered: