Search Issue Tracker
By Design
Votes
0
Found in
2021.3.23f1
2022.2.16f1
2023.1.0b13
2023.2.0a11
Issue ID
UUM-33959
Regression
No
Tilemap.GetTilesRangeNonAlloc generates an array of Tiles outside the given range
Reproduction steps:
1. Open the attached “My project.zip“ project
2. Open the “SampleScene” scene
3. Enter Play mode
4. Select “Tilemap” GameObect and observe “Start Position”, “End Position” and positions of the generated elements in “ddd” Script Component
Expected result: Generated Elements positions are between “Start Position” and “End Position”
Actual result: Generated Elements positions are not between “Start Position” and “End Position”
Reproducible with: 2021.3.23f1, 2022.2.16f1, 2023.1.0b13, 2023.2.0a11
Could not test with: 2020.3.47f1 (Errors in the Console)
Reproduced on: macOS Monterey 12.6 (Intel), Windows 10 (by the reporter)
Note: Also reproducible in Build
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Text render issues and various exceptions in TextCore when using TextSettings option "Match Material Presets"
- NullReferenceException error is thrown when unpacking multiple instances of the same UI Document
- URP Decal Projectors don't render when they are hidden in the Hierarchy, unlike other GameObjects
- Reflection Probe “adjusting number of stops to over or under expose the texture” setting does not update in Scene realtime
- UI Toolkit rendered text breaks when toggling FontWeight styles through code
Resolution Note:
Hi,
As detailed in the Scripting API documention found at https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.GetTilesRangeNonAlloc.html, GetTilesRangeNonAlloc will begin at the given starting position and iterate through all available Z Positions, then through the X and Y positions until it reaches the ending position. This will scan all X positions above the start position up to the end position, which can be outside of given X values (see example at the bottom in Scripting API documentation).
If you want to get Tiles within the bounds, please use Tilemap.GetTilesBlockNonAlloc instead (https://docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.GetTilesBlockNonAlloc.html).