Unity2D_Grids
GettingStarted
Type
Uniform
cell has the same shape and orientation
RectGrid
DiamondGrid
Hex
PointyHexGrid
FlatHexGrid
Spliced
cells may not have the same shape or orientation
Tri
PointyTriGrid
FlatTriGrid
Rhomb
PointyRhombGrid
FlatRhombGrid
CairoGrid
grids made from splicing the cells of a uniform grid into new, smaller cells
The original grid that was spliced is called the spliced grid’s base grid
Comp
Grid Point
use to access the contents of a particular cell
In general, a point can be anything???
Map
A map is the thing that converts between Unity coordinates, and grid coordinates
Maps supports several operations, including transformations, alignment functions, and anchoring functions
Custom
Op
ShapeInfo
Project
Unity
Hiearchy(Editor)
(Scene)
ImageToGridd.unity
MainCamera
Grid
(comp)
Flat Hex Tile Grid Builder
ImageToGrid
(Texture)
WorldMap.tga
(config)
TextureType
Advanced
NonPowero2
None
Read/Write Enabled
true
//why ???
Import Type
Default
AlphaFromGrayscale
false
ByPass sRGB Sample
true
SpriteMode
none
GenerateMipMaps
false
WrapMode
clamp
FilterMode
Bilinear
AnisoLevel
1
(children)
...Grid Hex collections...
Project
GameLogic
Plugins
Grids
Unity
Editor
Editors
FlatHexTileGridEditor.cs
Scripts
(GridBehaviour)
ImageToGrid.cs
using
Gamelogic.Grids;
public class ImageToGrid : GridBehaviour<FlatHexPoint> { ... }
(var)
public
Texture2D
texture;
(func)
override
public
void
InitGrid(){ ... }
var
imageMap =
new FlatHexMap(Vector2.one)
.WithWindow(new Rect(0, 0, texture.width, texture.height))
.Stretch(Grid);
foreach
(var point in Grid){ ...}
var imageCoordinate = imageMap[point];
Grid[point].Color = texture.GetPixel((int) imageCoordinate.x, (int) imageCoordinate.y);
Init
1
define the grid structure.
2
Next, we need to define a map
3
The next step is to instantiate our cells, and put them in the right positions using our map.
4
To make our cells clickable, we need to process mouse inputs: