Loading...
Loading...
Compare original and translation side by side
sprite-segment-3x3gridsprite-segment-3x3gridStep 1: sprite-segment-3x3grid Step 2: Create TilingRules
+--------------------------+ +--------------------------+
| Analyze each Sprite | | Parse text patterns |
| using color matching | -> | Map to neighbor rules |
| Output: text pattern | | Sort by specificity |
+--------------------------+ +--------------------------+sprite-segment-3x3gridStep 1: sprite-segment-3x3grid Step 2: Create TilingRules
+--------------------------+ +--------------------------+
| Analyze each Sprite | | Parse text patterns |
| using color matching | -> | Map to neighbor rules |
| Output: text pattern | | Sort by specificity |
+--------------------------+ +--------------------------+sprite-segment-3x3gridsprite-segment-3x3gridstring pattern = SpriteSegment3x3Grid.AnalyzeSpriteGrid(sprite, matchThreshold: 0.75f);sprite-segment-3x3gridstring pattern = SpriteSegment3x3Grid.AnalyzeSpriteGrid(sprite, matchThreshold: 0.75f);[TopRow] / [MiddleRow] / [BottomRow]X.*X X X / X * X / . . .[TopRow] / [MiddleRow] / [BottomRow]X.*X X X / X * X / . . .| Symbol | RuleTile Neighbor | Value | Behavior |
|---|---|---|---|
| | 1 | Neighbor must be an instance of this RuleTile |
| | 0 | Position not added to neighbors list |
| (center) | N/A | Ignored - represents the tile itself |
m_Neighborsm_NeighborPositions| 符号 | RuleTile邻居 | 值 | 行为 |
|---|---|---|---|
| | 1 | 邻居必须是此RuleTile的实例 |
| | 0 | 位置不添加到邻居列表 |
| (中心) | N/A | 忽略 - 表示瓦片本身 |
m_Neighborsm_NeighborPositionsGrid Layout: Unity Vector3Int positions:
[0] [1] [2] (Top) (-1,1,0) (0,1,0) (1,1,0)
[3] [*] [5] (Middle) (-1,0,0) --- (1,0,0)
[6] [7] [8] (Bottom) (-1,-1,0) (0,-1,0) (1,-1,0)| Index | Position | Vector3Int |
|---|---|---|
| 0 | Top-Left | |
| 1 | Top | |
| 2 | Top-Right | |
| 3 | Left | |
| 4 | Center | (skipped) |
| 5 | Right | |
| 6 | Bottom-Left | |
| 7 | Bottom | |
| 8 | Bottom-Right | |
Grid Layout: Unity Vector3Int positions:
[0] [1] [2] (Top) (-1,1,0) (0,1,0) (1,1,0)
[3] [*] [5] (Middle) (-1,0,0) --- (1,0,0)
[6] [7] [8] (Bottom) (-1,-1,0) (0,-1,0) (1,-1,0)| 索引 | 位置 | Vector3Int |
|---|---|---|
| 0 | 左上 | |
| 1 | 上 | |
| 2 | 右上 | |
| 3 | 左 | |
| 4 | 中心 | (跳过) |
| 5 | 右 | |
| 6 | 左下 | |
| 7 | 下 | |
| 8 | 右下 | |
filterToKnownPatterns: falsefilterToKnownPatterns: falseThis| This Count | Example Pattern | Priority |
|---|---|---|
| 8 | | First |
| 5 | | ... |
| 3 | | ... |
| 0 | | Last |
This| This数量 | 示例模式 | 优先级 |
|---|---|---|
| 8 | | 最先 |
| 5 | | ... |
| 3 | | ... |
| 0 | | 最后 |
m_OutputTilingRuleOutput.OutputSprite.Singlem_Sprites[0]m_DefaultSpritem_OutputTilingRuleOutput.OutputSprite.Singlem_Sprites[0]m_DefaultSpritesprite-segment-3x3grid/.ThisXm_Neighborsm_NeighborPositionsm_DefaultSpritesprite-segment-3x3grid/.ThisXm_Neighborsm_NeighborPositionsm_DefaultSpritescripts/| File | Description |
|---|---|
| Core implementation with |
| Editor window example ( |
| Manual two-step workflow for finer control over analysis |
scripts/| 文件 | 描述 |
|---|---|
| 核心实现,包含 |
| 编辑器窗口示例( |
| 手动两步工作流,用于对分析进行更精细的控制 |
// Get sprites and create rules in one call
var rules = TilemapRuleTileCreateFromSegment.CreateRuleTileFromSprites(
sprites, matchThreshold: 0.75f, colorTolerance: 0.04f);
// Apply to RuleTile
var ruleTile = ScriptableObject.CreateInstance<RuleTile>();
TilemapRuleTileCreateFromSegment.ApplyRulesToTile(ruleTile, rules);// Get sprites and create rules in one call
var rules = TilemapRuleTileCreateFromSegment.CreateRuleTileFromSprites(
sprites, matchThreshold: 0.75f, colorTolerance: 0.04f);
// Apply to RuleTile
var ruleTile = ScriptableObject.CreateInstance<RuleTile>();
TilemapRuleTileCreateFromSegment.ApplyRulesToTile(ruleTile, rules);| Tile Type | Pattern | This Count |
|---|---|---|
| Fully surrounded (inner tile) | | 8 |
| Top left corner missing | | 7 |
| Top right corner missing | | 7 |
| Bottom left corner missing | | 7 |
| Bottom right corner missing | | 7 |
| Top corners missing | | 6 |
| Bottom corners missing | | 6 |
| Left corners missing | | 6 |
| Right corners missing | | 6 |
| Top Left and Bottom Right diagonal corners missing | | 6 |
| Top Right and Bottom Left diagonal corners missing | | 6 |
| Top Left, Top Right and Bottom Left corners missing | | 5 |
| Top Left, Top Right and Bottom Right corners missing | | 5 |
| Top Left, Bottom Left and Bottom Right corners missing | | 5 |
| Top Right, Bottom Left and Bottom Right corners missing | | 5 |
| Cross Section | | 4 |
| Flat edge (Bottom) | | 5 |
| Flat edge (Top) | | 5 |
| Flat edge (Left) | | 5 |
| Flat edge (Right) | | 5 |
| L-Shape, Point Right | | 4 |
| L-Shape, Point Bottom | | 3 |
| L-Shape, Point Left | | 4 |
| L-Shape, Point Top | | 3 |
| L-Shape Inverse, Point Left | | 4 |
| L-Shape Inverse, Point Bottom | | 3 |
| L-Shape Inverse, Point Right | | 4 |
| L-Shape Inverse, Point Top | | 5 |
| T-Shape, face down | | 3 |
| T-Shape, face top | | 3 |
| T-Shape, face left | | 3 |
| T-Shape, face right | | 3 |
| Horizontal bridge | | 2 |
| Vertical bridge | | 2 |
| Corner piece, Bottom Right | | 3 |
| Corner piece, Bottom Left | | 3 |
| Corner piece, Top Left | | 3 |
| Corner piece, Top Right | | 3 |
| Edge end, Bottom Right | | 2 |
| Edge end, Bottom Left | | 2 |
| Edge end, Top Left | | 2 |
| Edge end, Top Right | | 2 |
| Single isolated tile, Left | | 1 |
| Single isolated tile, Right | | 1 |
| Single isolated tile, Top | | 1 |
| Single isolated tile, Bottom | | 1 |
| Center | | 0 |
| 瓦片类型 | 模式 | This数量 |
|---|---|---|
| 完全包围(内部瓦片) | | 8 |
| 左上角缺失 | | 7 |
| 右上角缺失 | | 7 |
| 左下角缺失 | | 7 |
| 右下角缺失 | | 7 |
| 上角缺失 | | 6 |
| 下角缺失 | | 6 |
| 左角缺失 | | 6 |
| 右角缺失 | | 6 |
| 左上和右下对角缺失 | | 6 |
| 右上和左下对角缺失 | | 6 |
| 左上、右上和左下角缺失 | | 5 |
| 左上、右上和右下角缺失 | | 5 |
| 左上、左下和右下角缺失 | | 5 |
| 右上、左下和右下角缺失 | | 5 |
| 十字交叉 | | 4 |
| 平边(下) | | 5 |
| 平边(上) | | 5 |
| 平边(左) | | 5 |
| 平边(右) | | 5 |
| L形,指向右 | | 4 |
| L形,指向下 | | 3 |
| L形,指向左 | | 4 |
| L形,指向上 | | 3 |
| L形反向,指向左 | | 4 |
| L形反向,指向下 | | 3 |
| L形反向,指向右 | | 4 |
| L形反向,指向上 | | 5 |
| T形,面朝下 | | 3 |
| T形,面朝上 | | 3 |
| T形,面朝左 | | 3 |
| T形,面朝右 | | 3 |
| 水平桥 | | 2 |
| 垂直桥 | | 2 |
| 角块,右下 | | 3 |
| 角块,左下 | | 3 |
| 角块,左上 | | 3 |
| 角块,右上 | | 3 |
| 边缘端点,右下 | | 2 |
| 边缘端点,左下 | | 2 |
| 边缘端点,左上 | | 2 |
| 边缘端点,右上 | | 2 |
| 单个独立瓦片,左 | | 1 |
| 单个独立瓦片,右 | | 1 |
| 单个独立瓦片,上 | | 1 |
| 单个独立瓦片,下 | | 1 |
| 中心 | | 0 |
sprite-segment-3x3gridThis*HexagonalRuleTileIsometricRuleTilesprite-segment-3x3gridThis*HexagonalRuleTileIsometricRuleTilesprite-segment-3x3gridsprite-segment-3x3gridsprite-segment-3x3gridsprite-segment-3x3gridsprite-segment-3x3gridPackages/com.unity.2d.tilemap.extras/Runtime/Tiles/RuleTile/RuleTile.cssprite-segment-3x3gridPackages/com.unity.2d.tilemap.extras/Runtime/Tiles/RuleTile/RuleTile.cs