TilePlus Version 5
Unity3D Tilemap Extension
Loading...
Searching...
No Matches
TilePlus.TpZoneManagerLib Class Reference

Utility methods for working with the Zone Manager. More...

Static Public Member Functions

static void UpdateGuidLookup (ZoneReg loadedZoneReg, ZoneReg newGuidZoneReg, Dictionary< Guid, Guid >? forwardLookup, Dictionary< Guid, Guid >? reverseLookup)
 Given an asset registration loaded from a file system, after unpacking from JSON (or equivalent), take the GUIDs from the last run of the app and find matching tiles in a new asset reg returned from LoadTileFab. Add matches to forward and reverse lookup tables, the latter is used to delete entries when a chunk is unloaded. If you're trying to do this some other way then use this as a guide and note that there's a property in TpLib that lets you add your own GUID lookup tables if you want.
static Vector2Int OrthographicCameraViewDimensions (Camera cam, int sizeOfChunks, Vector2Int? padding=null)
 Create a Vector2Int with the size of the camera view dimensions, rounded up to the nearest EVEN integer values. The EVEN values part is very important if you decide to implement this in some other fashion for a non-ortho camera.
static int NumberOfChunksInCameraView (Vector2Int cameraViewDims, int chunkSize)
 Calculate the number of Chunks of chunkSize in the Camera view.
static int SubdivideRectInt (RectInt input, int subdivisionSize, List< RectInt >? output, TpZoneManager? zoneManager)
 Given an input RectInt subdivide it into RectInts of a specific size.

Detailed Description

Utility methods for working with the Zone Manager.

Member Function Documentation

◆ NumberOfChunksInCameraView()

int TilePlus.TpZoneManagerLib.NumberOfChunksInCameraView ( Vector2Int cameraViewDims,
int chunkSize )
static

Calculate the number of Chunks of chunkSize in the Camera view.

Parameters
cameraViewDimsReturn value from OrthographicCameraViewDimensions
chunkSizeSize of chunks (4,6,8....n) where N is always even.
Returns
-1 for error

◆ OrthographicCameraViewDimensions()

Vector2Int TilePlus.TpZoneManagerLib.OrthographicCameraViewDimensions ( Camera cam,
int sizeOfChunks,
Vector2Int? padding = null )
static

Create a Vector2Int with the size of the camera view dimensions, rounded up to the nearest EVEN integer values. The EVEN values part is very important if you decide to implement this in some other fashion for a non-ortho camera.

Parameters
camThe camera to use when calculating.
sizeOfChunksThe size of chunks. Obtain from ZoneManager.DefaultLocator.size.x if possible.
paddingEnlarge the area by multiples of the chunk size (as obtained from ZoneManager) if not null. Note that if the result is not EVEN numbers then an additional one unit will be added
Returns
the camera view dimensions with optional padding. Vector2Int.zero is returned if the cam isn't orthographic. .

◆ SubdivideRectInt()

int TilePlus.TpZoneManagerLib.SubdivideRectInt ( RectInt input,
int subdivisionSize,
List< RectInt >? output,
TpZoneManager? zoneManager )
static

Given an input RectInt subdivide it into RectInts of a specific size.

Parameters
inputThe source RectInt
subdivisionSizethe size of each new RectInt. If not even, this value is rounded up WITHOUT a warning. Normally this should just be the chunk size which is easily obtained via a TpZoneManager property
outputa List of RectInts where the output is placed. Cleared on entry after error checks.
zoneManagerZone manager reference.
Returns
the actual subdivision size used after rounding (if any). If value is 0 then that's an error.

Note that this works correctly since chunks have have even-number size. It errs on the side of returning too many locations rather than fewer which is fine for the ZoneManager system.

◆ UpdateGuidLookup()

void TilePlus.TpZoneManagerLib.UpdateGuidLookup ( ZoneReg loadedZoneReg,
ZoneReg newGuidZoneReg,
Dictionary< Guid, Guid >? forwardLookup,
Dictionary< Guid, Guid >? reverseLookup )
static

Given an asset registration loaded from a file system, after unpacking from JSON (or equivalent), take the GUIDs from the last run of the app and find matching tiles in a new asset reg returned from LoadTileFab. Add matches to forward and reverse lookup tables, the latter is used to delete entries when a chunk is unloaded. If you're trying to do this some other way then use this as a guide and note that there's a property in TpLib that lets you add your own GUID lookup tables if you want.

Parameters
loadedZoneReg"OLD" asset registration from saved asset registrations
newGuidZoneReg"NEW" asset registrations as output from LoadTileFab.
forwardLookupforward oldGuid-to-newGuid mapping
reverseLookupreverse newGuid-to-oldGuid reverse mapping

The documentation for this class was generated from the following file:
  • /Users/jms/Documents/Tpt_55/TPT55/Assets/Plugins/TilePlus/Runtime/FabAndZone/StaticLib/TpZoneManagerLib.cs