The latest HexKit update is live on the Asset Store.
Editor integration has started creeping into HexKit! Version 1.2 introduces the HexLocation and HexFacing behavior scripts. When attached to an object, these provide editor facilities for hex grid placement and rotation. HexLocation can be used with snapping turned off to track the HexCoord location of an object as it moves through real space. HexFacing has five operation modes, selected from a drop-down in the editor (an enumeration script-side), allowing it to fit every usage I could imagine for it, including some specifically intended for sprites. A dedicated sprite behavior, which understands things like mirroring, is planned as a future counterpart to HexFacing.
A new version of Radiate() has been added, allowing partial shadows! It can be used for some nice lighting effects, but it can serve to model anything diminished by interposing objects: sound levels, heat or explosions that might be partially absorbed, etc. The original Radiate() has been redesigned for consistency, changing both its method signature and the format of the delegate function it uses. Conveniently, this means that the old Radiate() could be kept around and will keep working with no changes to existing code.
The last big news is that Unity 4.5.0 has made HexCoordinate completely obsolete. Like the old Radiate(), it’s still in the package to avoid breaking anything, but it’s buried in a deep subfolder to minimize confusion. HexCoord is now serializable, and public HexCoord fields can be edited directly from the Unity Inspector, preserving their data in prefabs etc.
And as usual, HexCoord got a few new functions too. Here’s the full changelog:
== GENERAL ==
Documentation:
- Added ELI5 for Behaviors vs. Logic.
- Updated to reflect all user-visible changes and additions.
Folder Structure:
- Moved existing classes, as well as the Internal folder, to a new Logic folder.
- Added a Behaviors folder for the new MonoBehavior additions.
== BEHAVIORS ==
HexLocation: (new)
- Enables grid-snapping in the editor.
- Can also be used to find location on a grid, without snapping.
HexFacing: (new)
- Constrains rotation to hex-grid cardinals and diagonals in or out of editor.
- Several constraint modes (and some non-constraining) are provided, intended to work well with sprites.
== LOGIC ==
HexCoord:
- Added PolarNeighbor(), gets next/previous hex in same ring from origin, faster than static AtPolar()
- Added AngleToHalfSextant(), HalfSextantToAngle()
- Improved behavior of CartesianBoundingRectangle(), bounds were unnecessarily large in some cases.
- Unity 4.5.0 can serialize structs! HexCoord is now serializable.
- Readonly fields aren't exposed to the Inspector, so HexCoord is no longer immutable.
- Updated Scale() to modify in-place. (Still returns, to avoid code breakage.)
HexCoordinate:
- Obsolete. Still in the package (again, avoid breakage) but moved to a Deprecated folder inside Internal Classes.
HexKit:
- Added a variant Radiate which allows partial transparency (arbitrary integer, like MoveCost pathfinding).
- Binary Radiate() changed to provide consistent API and feature set.
- Method signature change allowed old binary Radiate() to remain, but it is deprecated.
HexRayHit: (new)
- Abstract decorator class for variable-transparency Radiate(), used like HexPathNode.