Grids 1.8

Grids 1.8 is finally out 🙂

This is quite a big change – from being an abstract data structure library, we turned Grids into an editor extension, which allows you to setup grids in the editor. On the surface, it is not a big change. We joke that we wrote 1000s of lines of code to eliminate the 10 or so lines you’d have to write to construct the grid and map. And in a sense, this is true – you still have to write your game logic, and this looks quite a bit like it did before – you use the grid data structure to access cells, and the map for doing world-to-grid point conversions. So what has really changed?

Foremost is of course that we did not just save you from writing the construction code – we also save you from running the game. This makes building levels (for certain types of games) much faster. The fact that you can hook in your own initialisation logic makes it possible to have quite a bit of functionality in the editor – this is particularly useful for levels that are generated procedurally.

There are of course also other small conveniences – for 2D games, if you implement your own GridBehaviour (the thing where you need to put your game logic), you have MousePosition that gives you the mouse position in grid coordinates. There are also OnClick events sent to both the grid behaviour, and individual cells. There are gizmos for cells showing grid coordinates, and you can use ordinary Unity tools to translate, rotate and scale the grid. Oh, and all our examples now use Unity sprites – no more dependence on NGUI!

We also moved cells from “example components” to API components. Right now, it makes it a bit easier to maintain our examples (especially future examples that we post on the web site). But it also makes it possible for us to make more important changes to some of our algorithms. To give one example, our AStar implementation use hash sets to store certain information per cell. Now that we are specifying cells, we could move some of this information into cells, and get some performance enhancements as a result (not least of which that result from fewer allocations!)

There are a few things many users want to do, such as these things (which are all related):

  • Use big grids, without loss of performance
  • Use scrollable grids that are only partially visible at any time
  • Use grids made from single meshes, rather than individual sprites

We posted examples of how to solve problems such as these on our site, but many users feel it should really be part of the library already. Before we had to tell them, “grids are data structures – rendering is up to you”. But the editor support now puts us in a different position. For now we do control the things that are rendered, and their construction. It is now much easier for us to provide grids with various performance enhancements that we could not before. We look forward to implement big grids, mesh grids (yes, that is why all builders are called XXXTileGridBuilder, to distinguish them from the XXXMeshGridBuilders of the future).

This version does not yet address all the scenarios typical Grids users will face. In particular, we do not have proper support in the editor for wrapped grids, arbitrary 3D maps, for generic spliced grids. We do not yet have an input structure for 3D games. (These are all still possible through code though!) And we have not quite worked out what is the way to make it easy to edit levels cell-per-cell.

In addition to the editor tools, we also made quite a few other changes – including adding several more grid types. In case you have not seen the video, here is it:

And the full list of features:

In this version, we

  • added grid builders that allows you to build grids in the editors, including the classes for supporting them, including
    • grid builder classes and their editors
    • classes for implementing custom maps and shapes that can be used with builders
    • classes that allows implementation of grid behaviours
    • cells and their editors
  • added LineGrid and related classes for making 1D grids.
  • added ArchimedeanSpiralMap for use with a LineGrid to map cells in a spiral.
  • added LayeredGrid and related classes for making 3D grids made from layers of 2D grids.
  • added GenericSplicedGrids and related classes for making arbitrary semi-regular grids.
  • added PointListMap that maps a sequence of LinePoints to an arbitrary set of world points.
  • added VoronoiMap for mapping 2D space to an arbitrary point set.
  • added IGridToWorldMap, an interface for one-way maps that can be used by maps that does the inverse mapping automatically.
  • added method GetNeighborHood for RectGrid that returns a square region of points around a given point.
  • added method Stretch to map building to make it easy to get a grid stretched over a rectangle.
  • added class PoissonDisk for generating a PoissonDisk sample of points.
  • added constructors to InspectableVectorPoint and InspectableSplicedVectorPoint that takes other points as parameters
  • added ToString methods to InspectableVectorPoint and InspectableSplicedVectorPoint.
  • made GetLongestConnected Obsolete (use GetLongestConnectedLine instead).
  • removed ToString and GetHashCode from IGridPoint interface (these are redundant).
  • made AnimatedMap also work with EditorApplication.timeSinceStartup.
  • fixed a bug with the edge grids of tri grids.
  • renamed “SuperRectGrid” to “NestedRectGrid”.
  • made enhancements to make Grids work better on iOS, including
    • rewriting certain methods to avoid problems with deep generics
    • adding more compiler hints for built-in cells
Scroll to Top