Skip to main content

Utilities

Various Utilities

PerkinsStringUtils

This small library has one function: Word Wrapping for the UiAsciiString Tile. Attribution in C# source and in "Third Party Notices" in the Asset Store package.

EditorBridge

This provides Editor support for Tiles and other code which otherwise would not be able to access code in an Editor folder. Doesn't exist in a build.


TileUtils

TpTileUtils is a set of utility/convenience functions which are very useful when dealing with tiles and Tilemaps.

Transform Utilities

These can be used to get or set tilemap sprite transform components and colors.

BoundsInt Utilities

BoundsInts are used throughout Tilemap-land and inside the TilePlus system.

4- and 8-way Position Utilities

Given a tile's position, there are either four or 8 possible adjacent locations.

  • Up, Right, Down, Left

  • Up, RightUp, Right, RightDown, Down, LeftDown, Left, LeftUp

These positions are encoded into Enums: the values are in clockwise order.

Utilities in this group can be used to obtain adjacent, opposite, or perpendicular positions.

Others

Simple block deletions, tile sprite utilities, and RectInt to BoundsInt conversions.

Complete List

Transform Utils

ScaleMatrix(Vector3 scale, Vector3 position) : Matrix4x4

RoundVector3(Vector3 input, int digits) : Vector3

GetTransformComponents(Tilemap map, Vector3Int position, out Vector3 tPosition, out Vector3 tRotation, out Vector3 tScale) : void

GetTransformComponents(Matrix4x4 transform, out Vector3 tPosition, out Vector3 tRotation, out Vector3 tScale) : void

GetTransformRotation(Tilemap map, Vector3Int position) : Vector3

GetTransformPosition(Tilemap map, Vector3Int position) : Vector3

GetTransformScale(Tilemap map, Vector3Int position) : Vector3

SetTransform(Tilemap map, Vector3Int position, Vector3 tPosition, Vector3 tRotation, Vector3 tScale) : Matrix4x4

MakeMatrix2D(Vector3 position, Vector3 rotation, Vector3 scale) : Matrix4x4

GetTileSpriteRotation(TilePlusBase tpb) : Vector3

SetTileSpriteRotation(TilePlusBase tpb, Vector3 value, bool constantScaleAndPosition) : void

GetTileSpritePosition(TilePlusBase tpb) : Vector3

SetTileSpritePosition(TilePlusBase tpb, Vector3 value, bool constantRotationAndScale) : void

GetTileSpriteColor(TilePlusBase tpb) : Color

SetTileSpriteColor(TilePlusBase tpb, Color value) : void

GetTileSpriteScale(TilePlusBase tpb) : Vector3

SetTileSpriteScale(TilePlusBase tpb, Vector3 value, bool constantPositionAndRotation) : void

Bounds Int Utils

CreateBoundsInt(Vector3Int position, Vector3Int size, bool forceZto1) : BoundsInt

RandomPosInBounds(Bounds bounds) : Vector3

BoundsFromOrthoCamera(Camera? camera, bool square, float scale, bool zeroZ) : Bounds

LargestBoundsInt(IEnumerable<BoundsInt> input) : BoundsInt

4 Way Position Utils

DirectionType4 (Enum): None, Up, Right, Down, Left

NextDirectionType4(DirectionType4 d) : DirectionType4

Get4WayAdjacent(Vector3Int center) : Vector3Int[]

Get4WayAdjacentHashSet(Vector3Int center, HashSet<Vector3Int>? hashSet, bool clear) : void

Get4WayRandomDirection() : DirectionType4

Get4WayPerpendicular(Vector3Int center, DirectionType4 dir, Vector3Int[]? output) : void

Get4WayNextInOppositeDir(Vector3Int position, DirectionType4 dir) : Vector3Int

Get4WayOppositeDirectionType(DirectionType4 dir) : DirectionType4

Get4WayAdjacent(Vector3Int position, DirectionType4 dir) : Vector3Int

8 Way PositionUtils

DirectionType8 (Enum): None, Up, RightUp, Right, RightDown, Down, LeftDown, Left, LeftUp

NextDirectionType8(DirectionType8 d) : DirectionType8

Get8WayAdjacent(Vector3Int center) : Vector3Int[]

Get8WayAdjacentHashSet(Vector3Int center) : HashSet<Vector3Int>

GetRandomDirection() : DirectionType8

Miscellaneous

DeleteTilesFromPositionList(Tilemap map, Vector3Int[] positions) : void

DeleteTilesFromPositionList(Tilemap map, IEnumerable<Vector3Int> positions) : void

DeleteTilePlusBaseBlock(Tilemap map, IEnumerable<TilePlusBase> tiles) : void

GetTrueBoundsForTileSprite(Tilemap? map, Vector3Int position) : Bounds

GetTileSpriteIntegerSize(Tilemap map, Vector3Int position) : Vector2Int

GetTileSpriteSize(Tilemap map, Vector3Int position) : Vector2

GridPositionsSurrounding(Vector3Int gridPosition) : RectInt

RectIntFromBoundsInt(BoundsInt boundsInt, Vector3Int offset) : RectInt