This is a simple chunking system based on TileFabs.
More...
|
| virtual bool | Initialize (out TpZoneManager? zm, Tilemap[]? managedTilemaps=null, Vector2Int? padding=null, ReinitMode reinitMode=ReinitMode.DoNotResetZoneManager) |
| | Startup the chunking system: base class accepts ortho cam only!
|
| async Awaitable< bool > | UpdateTickAsync (Vector3 worldPosition, Vector2Int? padding=null, Func< ZoneReg, object, TpZoneManager, bool >? unloadingFilter=null, Func< object, TpZoneManager, TileFabLoadParams, LoadFilterResult >? loadingFilter=null, object? userData=null, Action< RectInt >? preFilter=null, bool ignoreThrottling=false) |
| | Call this whenever you want to update the chunking system, eg after the Player moves.
|
This is a simple chunking system based on TileFabs.
◆ LoadFilterResult
Return value from UpdateTick load filter.
| Enumerator |
|---|
| FillZone | Fill this zone. It's OK!
|
| LeaveZoneEmpty | Leave this zone empty. It may be filled later though...
|
| MarkZoneFilledButLeaveEmpty | Leave this zone empty but mark it reserved so it stays empty.
Only as long as it is within the CamViewport+Padding.
|
| FillZoneAndMarkImmortal | Fill the Zone and mark it immortal. It'll never be deleted.
|
◆ ReinitMode
When re-initializing this layout, this value is used to determine if and how to reinit the underlying ZoneManager.
| Enumerator |
|---|
| DoNotResetZoneManager | Don't reset it at all.
|
| ResetZoneManagerOnly | Reset only the zone manager and not its event subscriptions.
|
| ResetZoneManagerAndItsEvents | Reset the zone manager AND its event subscriptions.
|
◆ Initialize()
Startup the chunking system: base class accepts ortho cam only!
- Parameters
-
| zm | Zone manager instance used by this layout is placed in this out parameter |
| managedTilemaps | Tilemaps to be used by this layout. If not provided, maps are taken from Tilemap children to m_Grid field in component. |
| padding | [Nullable] extra size added to Camera viewport, can help hide load/unload transitions from Camera viewport. If null, uses value from this component. |
| reinitMode | A value from the ReinitMode enum. If changing the selector (akin to 'new scene') then a zone manager for this layout already exists. This enum value determines if and how the ZoneManager is reinitialized. This doesn't happen on the first use when there's no zone manager. |
- Returns
- false for any errors.
Using this method a second time resets all chunk-related information. How to calc size of the world: example sizeOfWorld: If size of chunks is 64, then the TileFabs must be 64x64 (although this is not enforced). This means that the number of Grid units is 64 x 64 for each TileFab. You probably want to set some limit of how far to move in any direction. Let's say you didn't want to more more than 1024 Grid units in any direction so that would mean that the world was 1024 x 1024 Grid units. Divide that by 64 to get 16. 16 x 16 is the grid of TileFabs, that is a total of 256 TileFabs. In essence you are using the TileFabs as part of a larger grid.
◆ UpdateTickAsync()
| async Awaitable< bool > TilePlus.TpZoneLayout.UpdateTickAsync |
( |
Vector3 | worldPosition, |
|
|
Vector2Int? | padding = null, |
|
|
Func< ZoneReg, object, TpZoneManager, bool >? | unloadingFilter = null, |
|
|
Func< object, TpZoneManager, TileFabLoadParams, LoadFilterResult >? | loadingFilter = null, |
|
|
object? | userData = null, |
|
|
Action< RectInt >? | preFilter = null, |
|
|
bool | ignoreThrottling = false ) |
Call this whenever you want to update the chunking system, eg after the Player moves.
- Parameters
-
| ignoreThrottling | Set true to ignore any throttling. Typical use: on the first call if you're filling in the initial area of the scene and you're this layout component uses either throttling fabs or bundles. If true, those are ignored |
| worldPosition | Current Camera position. Note that if cam pos is lerped to player player's transform.position could work better. |
| padding | Increase the size implied by the cam view in CHUNKSIZE units. usually this is desireable, by at least one unit, to provide a border around the camera view so no flickering is observed as TileFabs are loaded and unloaded. –IF NULL – the padding is from a field in the component |
| unloadingFilter | A func taking a ZoneRef and returning a bool. This filter is used when removing zones OUTSIDE the viewport area. The ZoneRef has the 'offset' within it: the position of the Tilefab that will be deleted as well as the ZoneManager instance and a user object passed to this method when invoked. This is invoked when deleting: return False to inhibit deletions. Note tha this loadingFilter is not used when the ZoneRef is marked immortal. This unloadingFilter is useful if there are areas that you want the chunking system to avoid deleting and you don't want to mark them immortal. |
| loadingFilter | Same as unloadingFilter but used when ADDING chunks INSIDE the viewport area. |
| userData | passed to the Filter - this can be anything that you want. |
| preFilter | If this Action is not null it gets sent the ViewPort+Padding RectInt. This can be used to remove any spawned GameObjs OUTSIDE this RectInt bounds. |
- Returns
- False if something went wrong or if nothing was done, otherwise true.
in spite of the name, this doesn't need to be called on every Update!! For example, it doesn't make sense to repeatedly call this when within one Zone ie within a square area defined by the chunkSize, as the result would be the same each time. It'd also be really inefficient. ALSO: PLEASE NOTE that it your responsibility to ensure that the supplied TileFab reference has the same chunk size. IE, if the chunksize is set at 32 don't provide a 16x16 or 64 x 64 chunk as a return value for this Func. It's called many times so precalculate when possible.
◆ m_Active
| bool TilePlus.TpZoneLayout.m_Active = true |
◆ m_CameraViewPadding
| Vector2Int TilePlus.TpZoneLayout.m_CameraViewPadding = new(2, 2) |
Extra padding around camera viewport.
◆ m_ChunkSelector
A selector to use for this layout.
◆ m_ChunkSize
| int TilePlus.TpZoneLayout.m_ChunkSize = 16 |
Chunk size used for this layout.
◆ m_DebugMessages
| bool TilePlus.TpZoneLayout.m_DebugMessages |
Show tilefab load results in console.
◆ m_DefaultInitializer
The default initializer for ALL Tscenes using this LayoutSpec. Can be overridden in SelectorLayout definitions.
◆ m_DoNotLoad
| bool TilePlus.TpZoneLayout.m_DoNotLoad |
For diags, this inhibits tilefab loading so only the camera rect info is visible.
◆ m_Grid
| Grid? TilePlus.TpZoneLayout.m_Grid |
Parent Grid for all tilemaps used by this layout.
◆ m_LayoutName
| string TilePlus.TpZoneLayout.m_LayoutName = "Use a unique name" |
Unique name for this Scene Layout. ChunkedSceneManager will issue warning and ignore instances of this component with duplicate names.
◆ m_ReferenceCamera
| Camera? TilePlus.TpZoneLayout.m_ReferenceCamera |
The camera that will be used determine what's loaded and unloaded.
◆ m_ShowCameraRect
| bool TilePlus.TpZoneLayout.m_ShowCameraRect |
If true, a marquee is drawn for the camera rect.
◆ m_ShowZones
| bool TilePlus.TpZoneLayout.m_ShowZones |
If true, a marquee is drawn for the Layout system zones.
◆ m_ThrottleBundleDelay
| float TilePlus.TpZoneLayout.m_ThrottleBundleDelay = 0.01f |
Throttle the TileBundle loads if throttleTileBundle is true.
◆ m_ThrottleTileBundle
| bool TilePlus.TpZoneLayout.m_ThrottleTileBundle |
Throttle TileBundle loads if true.
◆ m_ThrottleTileFab
| bool TilePlus.TpZoneLayout.m_ThrottleTileFab |
Throttle Tilefab loads if true.
◆ m_ThrottleTileFabDelay
| float TilePlus.TpZoneLayout.m_ThrottleTileFabDelay = 0.01f |
Throttle the TileFab loads if the throttleTileFab is TRUE.
◆ m_WorldOrigin
| Vector3Int TilePlus.TpZoneLayout.m_WorldOrigin |
◆ m_ZoneManagerName
| string TilePlus.TpZoneLayout.m_ZoneManagerName = "" |
The name to use when creating a zone manager. Must be unique.
◆ EffectiveBounds
| BoundsInt TilePlus.TpZoneLayout.EffectiveBounds |
|
get |
Bounds Int of largest Bundle size offset by world origin.
◆ LastTileFabLoadResults
Access the load results from the last use of UpdateTick()
◆ LayoutZoneManager
Access the ZoneManager instance for this Layout.
◆ ZonesOutsideViewport
| List<ZoneReg> TilePlus.TpZoneLayout.ZonesOutsideViewport |
|
get |
This can be useful in a Selector.
The zones outside viewport.
The documentation for this class was generated from the following file:
- /Users/jms/Documents/Tpt_55/TPT55/Assets/Plugins/TilePlus/Runtime/FabAndZone/MonoComponents/TpZoneLayout.cs