Below is a package that allows you to use Grids with the hex and isometric tiles designed by Golden Skull Studios. In particular, it calculates suitable sorting order for tiles so that they are rendered in the correct order, even when stacked vertically.
The package contains:
- A custom cell component that supports various features of the tile set:
- Sprite and color
- Height offset
- Vertical stacking
- Two default prefabs (one for hex and one for iso) that uses the component above, and are suitable for use with grid builders.
- A custom GridBehaviour that does basic initialization of cells and allows you to add additional initialization.
- 3 custom initialization scripts (for each tile type):
- One that selects a random sprite from a list, and selects a random height offset or stack height.
- One that uses patterns (grid coloring functions) to select sprites and stack heights.
- One that takes offsets and stack heights from a height map, and selects sprites based on a height map too.
- Two example scenes (one for each tile type) that shows how to set up your grids using the scripts above. Each scene has examples for all three custom initialization scripts.
Download
GoldenSkullGridExtensions.unitypackage
How to import the packages
- In a new project, import Grids and the tile set that you want to use.
- Select all the sprites, and on the import settings, set the Pixels Per Unit to 1. This ensures unity units correspond to pixels. If you don’t do this, many examples won’t work.
- Import the package below. All the files are in the folder GoldenSkullGridExtensions.
If you only import one tile set, one of the example scenes won’t work. You can safely delete it. Everything else should work.
How to setup a scene to use these tiles
- Make sure your camera is orthographic, and that it’s size is half the screen height that you want to design for.
- Add a grid builder to your scene as normal. On an empty game object in your scene, add either the FlatHexTileGridBuilder or the DiamondTileGridBuilder component. Link in the HexCellPrefab or IsoCellPrefab, and configure the grid as you like.
- Add the GSHexGridBehaviour or GSIsoGridBehaviour component to the same game object.
- Optionally, add custom initialization scripts. You can use one of those we provide, or make your own. Configure them as you like.
- Optionally, configure the properties on the cell prefab:
- Tweak the Center Offset to control how coordinate gizmos are displayed.
- Tweak the Cell Dimensions to get a tighter or looser fit. The dimensions are the dimensions of the “flat” part of the cell (the part of the cell that is visible when all the heights are the same).
- Tweak the Stack Offset to determine how far tiles are displaced when stacked vertically.
How to use the custom initialization scripts
The custom initialization scripts we provide are examples of how you can initialize cells for your game. In general, you would not use these for your game, as you probably want to use your own logic. These examples should provide you with a good starting point though.

Random Sprite
This script selects sprites randomly, and assigns height offsets and stack heights randomly too. If max stack height is 1, then tiles won’t be stacked, as is shown on the far left. If the max height offset is 0, tiles won’t be offset, as is shown on the near left.
Pattern

This script selects sprites and stack heights based on a color function. Any repeating pattern can be configured this way. To understand how the three numbers determine the pattern, see What are grid colorings? Make sure you have enough sprites to support the pattern, otherwise you will get exceptions.
Height Map
This script selects sprites and heights based on a height map. Generally, you would either keep max stack height 1 (shown far left), or keep max scale 0 (shown near left). If you want the bottom layer to be completely flat (for water, for instance), tick the Flat First Level box. You can tweak the height of this first level, which is useful for liquids too. The frequency determine how the image is sampled. Tweak this value for denser / sparser sampling. Make sure the image you use is tileable, and has Read/Write enabled, and is sampled using bilinear filtering.
Implementing your own logic
Generally, you would probably implement your own cell so that it can handle any extra information you need for your game. For example, you may want to implement a tile type property that you can set in code that would automatically select the right sprite. You can then query this code in your game logic to work out what can happen on this cell. For more information see Making your own cells.
You would also probably want to implement your own initialization script. The easiest way to do this is to extend from GridBehaviour, and put all your logic in a method called Init. Note: normally grid initialization happens in the InitGrid method. However, this method is already defined in GSGridBehaviour, which sends a message to the Init method. For more information see Working with GridBehaviours.
Pingback: Golden Skull Studios Extension for Grids | Gamelogic