Other Assets

Specialized Scriptable Object assets

TilePlus Tile Asset Varieties

These are all project-level asssets.

These assets can be created from the Assets/Create/TilePlus menu except for the first three and TpChunkSelectorBase.

TpTileBundle and TpTileFab are assets created when you use the Tools/TilePlus/Prefabs/ Bundle Tilemaps menu command.

TpPrefabList is a list of TpPrefabSpawnerItems. Each item has the following fields:

TpTileList is like TpPrefabList, but for TPT tiles.

TpSlideShowSpriteSet has a list of TpSlideClips. Each clip has the following fields:

TpSpriteAnimationClipSet has a list of TpAniClips. Each clip has the following fields: Name: Name of the Clip Set

Please note that when adding a new clip to the asset: AnimationSpeed will be 0, will cause a runtime warning if OneShot is true. Internally, a value of 1 is used if AnimationSpeed is zero, which may produce unintended results.

Animated Tiles

TpAnimatedTile

TpAnimatedTile is a simple animated tile and if you want to learn about the code, it’s the simplest TPT Tile.

Public fields:

Note that for TpAnimatedTile the static tile is the tile sprite. For TpFlexAnimatedTile the sprite specified by a clip’s DefaultTileIndex value is displayed. If that doesn’t work (it’s incorrect or the sprite is null) then the static tile is the tile sprite.

If painting this tile via script, see the FAQ entry “Animated tile not animating.”

TpFlexAnimatedTile

TpFlexAnimatedTile is an upgraded TpAnimatedTile that adds the ability to have multiple animation sequences contained in an asset file. Once placed, you can select on a per-tile basis which animation sequence is used initially, and several other settings, including whether to play automatically when the Scene is loaded, and which sequence is in use. When using many animated tiles, the use of an asset is more memory efficient than TpAnimatedTile.

The asset file for this tile is TpSpriteAnimationClipSet, and its fields are mostly the same as those for TpAnimatedTile. You can create it from the Assets/Create menu.

Public fields:

When inspecting one of these tiles using the Selection Inspector, you’ll see a dropdown Clip to use where you can select the animation sequence from the ClipSet to be used when your game starts. This can also be changed via code.

If painting this tile via script, see the FAQ entry “Animated tile not animating.”  

TpSlideShow

TpSlideShow lets you display one Sprite at a time from a list of Sprites contained in an asset file. The initial Sprite to display can be changed, and you move from one Sprite to the next programmatically, with automatic wrapping or limiting, or set the displayed sprite directly.

Wrapping means that incrementing from the last slide returns to the first slide (or when decrementing, from the last slide to the first slide) and limiting means that incrementing from the last slide or decrementing from the first slide has no effect. This tile is used for the background in the BasicTiles demo.

The asset file for this tile is TpSlideShowSpriteSet, and its fields discussed in the Programmer’s Guide. You can create it from the Assets/Create menu.

Public fields:

The last three features listed above are discussed here.

When inspecting one of these tiles using the Selection Inspector, you’ll see a dropdown where you can select which slideshow set from the TpSlideShowSpriteSet to be used at start. This can also be changed via code.

Technically, the SlideShow tile uses the Tilemap's animation system but the animation is always on pause. Changing slides changes the animation parameters but only one sprite (slide) is shown at a time.

AnimatedSpawner

Animated Spawner is a subclass of TpFlexAnimatedTile. It responds to ActionToTile packets via the Messaging system or one can directly call methods that will spawn a tile. All of the Animation methods of FlexAnimatedTile are of course available.

Public Fields:

One might note that AnimatedSpawner and FlexAnimatedTile both have explicit declarations of MessageTargets (for the Messaging system) which take ActionToTile packets.

This shows the power of Explicit declarations: the MessageTarget in the FlexAnimatedTile superclass is ignored by the Messaging System because sending a message to an AnimatedSpawner instance is sent to the 'override' method with the highest level explict declaration. (oversimplification).

Special Tiles

TpBundleTile

TpBundleTile loads a TileBundle to the Tile's parent Tilemap.

This tile has a custom editor, use it to set up the Matrix via inspecting the project asset.

Immortalizer

TpImmortalizer tiles may be painted into a Zone (ie a square area of a particular size eg 8x8, 16x16 etc) to mark that Zone as Immortal when used with the Layout system. It's not useful outside of that environment.

Note that this tile is a convenience, but the implementation is part of your app, see the Layout for an example.

Tweener Tiles

TweenerFlex

This is the best tile to use when experimenting with tweens. When viewed in a TilePlus Selection inspector only the fields appropriate for the particular 'target' are displayed.

Note about Color tweens: there's no Ease Function for these. 'Lerp' is always used.

For example: scale

TweenFlexScale.png

For example: matrix

MatrixTween2.png

When tweening any of the Matrix varieties, EaseFunction is used for the Position tween, EaseRotation is used for the Rotation tween, and EaseScale is used for the Scale tween.

Matrix Hints

When using Matrix tweens you can tween the entire matrix (position, rotation, scale) or any of the components.

Tweener-matrixhints.png

One can use this to create, say, a Matrix tween that only affects rotation and position but not scale. This is equivalent to executing a Position and Rotation tween at the same time.

TweenSpec

This tile allows you to use one tween from a TweenSpec asset.

TweenSpecSeqTile.png

The Spec Index determine which tween from the asset is used.

TweenSpecSequence

This tile allows you to run an entire sequence from a TweenSpec asset.

TweenerSeqTile.png

It just plays the entire sequence. You can control the number of loops.

If Loop Interactive Mode is checked, the sequence is forced to not loop.

When the sequence completes, it restarts with a fresh set of value fom the Tween Spec asset. Hence, if you change values of this asset while the editor is Playing, such changes will be seen when the sequence restarts. As is true for project assets, the changes will remain after you exit play mode. It's a great way to play with sequences and Matrix-style tweens.

The TweenSpec asset

This is a project-level asset where you can set up one or more tweens. Use them independently with the TweenSpec tile or as a sequence using a TweenSpecSequence tile.

This asset has a custom UIElements inspector that works similarly to what you see in the TweenerFlex tile.

A great way to play with tweens and learn how they work with tiles is to use the TweenSpecSequence tile with the Loop Interactive Mode active. You can change the fields in the TweenSpec asset and see the change the next time that the sequence loops.

Zone-Based

AnimZoneLoader

This class is a subclass of TpFlexAnimated tile and inherits its fields and editor appearance.

It’s used to load archived Tilemaps from TpTileFab assets, which are created by the Tools/TilePlus/Prefabs/Bundle Tilemaps command.

IMPORTANT

It's somewhat obsoleted because of the Layout system and may NOT compatible with it.

Public fields:

Zone Managers and their uses are discussed here.

More about Preview

Preview loads the tiles into a preview tilemap or maps, if there are multiple TpTileBundle assets referenced by the TpTileFab asset. The preview is active until you click Preview again or the Editor’s Selection changes. When preview is active, you can change the loading offset and the preview area will change position.

Loading or previewing tiles depends on there being compatible Tilemaps that are named or tagged in such a way that the system can identity which Tilemap to use. This information is embedded in the TileFab asset when you create it. If you need to change it just edit the asset’s TileAssets section in the Project window.

The tile does not automatically load Tilemaps at runtime. Rather, you send a message to it via the TpLib SendMessage methods. As configured, it expects the message to contain a Vector3Int describing a position. If the position is within the Zone bounds, the tile uses TpLib’s PostTileEvent method to post a trigger event.

AnimZoneSpawner

This can be used to spawn prefabs and TPT tiles, using assets with lists of prefabs or tiles. This tile uses the Spawner service.

Prefabs can be unparented or parented to a Scene Object by using the GameObject name or tag.

Tiles can be painted on the same tilemap or on a different tilemap which you specify using a GameObject name or tag, or a reference. This tile can respond to a SendMessage containing a Vector3Int describing a position. If the position is within the Zone bounds, it will spawn prefabs or paint tiles as you’ve configured it. Alternatively, you can spawn/paint via code using the instance methods SpawnPrefab or PaintTile if this approach doesn’t suit you.

You can use either a TpTileList or a TpPrefabList asset (or both) to specify which tiles or prefabs (or both) to use with this tile.

Public fields include those from TpAnimZoneBase and its superclasses, and these additional fields. Public fields:

Tile Painting

When doing Tile painting you have several configuration options using PositioningMode, PaintingTilemap, PaintingTilemapNameOrTag, and Parenting mode. When painting tiles it’s important that the tile which is doing the painting is not painted over. Furthermore, since the tile occupies a position on a tilemap, you probably don’t want it to appear as an obstacle to a Player or NPC walking through the tile’s trigger zone (TpZoneBase or TpAnimZoneBase).

All these controls exist so that you can paint the this tile on a different Tilemap from the one that you use for pathfinding and character movement.

Paint one of these tiles on Tilemap A and use it to paint tiles on Tilemap B. When you do that, the tile needs to know which Tilemap to use. That’s done by setting ParentingMode appropriately and filling-in correct values for PaintingTilemap or PaintingTilemapNameOrTag.

Prefab Pooling in TpAnimZoneSpawner

AnimZoneSpawner uses the Spawner service which provides GameObject pooling.

When a TpAnimZoneSpawner tile instance’s StartUp is invoked and if SpawnMode is set to RandomPrefabs or PrefabsInOrder and if the TpPrefabList has any prefabs where the PoolInitialSize is nonzero, the tile will ask SpawningUtil to preload prefab instances. This only occurs on the first StartUp and will not occur if you change the TpPrefabList asset during runtime.

Note that preloading takes time, as each prefab must be instantiated, so choose the preload sizes carefully. If there’s no preload, the pool expands automatically as prefabs are instantiated and spawned.

Normally the pooler does not attach the pooled and/or preloaded prefabs to a parent GameObject. If this bothers you, head over to the Project folder Plugins/TilePlus/Runtime/Assets and drag the Tpp_PoolHost prefab into your scene. This prefab has an attached component which sets DontDestroyOnLoad so that the prefab persists between scene loads. The pooler looks for a GameObject with this specific name.

The pooler will automatically add a component of type TpSpawnLink to spawned prefabs if it doesn’t already exist. TpSpawnLink can also despawn the prefab after a timeout.

New In Version 5: if the spawned GameObject has a Collider2D or Collider component AND the TpSpawnlink instance on that GameObject has its m_IgnoreCollider field = false THEN a reference to the spawned GameObject is added to an internal HashSet of “Collidables” and the callback OnCollidableObjectSpawned is invoked.

Similarly, if a Collidable is despawner by the Spawner service the callback OnCollidableObjectDespawned is triggered.

A method IsCollidable() can be used to see if a GameObject is in the HashSet.

This feature was added as part of the Layout system upgrade, and is used to keep track of prefabs that are spawned by tiles or otherwise – its used to ensure that spawned prefabs in a Chunked Zone (region) can be removed when the Zone’s tiles are removed.

This can get complicated since spawned GameObjects may not be in the same position when they're deleted. Keeping track of them ensures that they are removed only when the Zone that they're actually in is removed.

The Layout system removes all tiles and GameObjects in a Zone, but it only handles GameObjects parented to one of the Tilemaps controlled by the layout system. The Layout system doesn’t know what GameObjects might have been spawned by tiles (such as TpAnimatedSpawner) or exactly what Zone the GameObjects might be in since they might have moved from their original spawning location.

ZoneAnimator

Like other Zone-type tiles, it depends on you sending it a message with a position using TpMessaging, the TilePlus messaging system. Depending on how the Tile is set up, various actions will occur at StartUp() and/or when the tile’s internal state changes from ‘position is within the Zone’ to ‘position is outside of the Zone’.

That state change occurs when a message with a new position being sent to the tile.

The Zone is set up in the TilePlusBase section seen when inspecting the tile.

It's merely a BoundsInt which describes an area relative to the tile’s position on a Tilemap.

The tile’s code is set up to handle six basic types of operation based on a value from the PrefabMode enumeration:

  1. PresentWhenNotInZone: Spawn the prefab when the tile’s Start method is executed; despawn it when the Zone is entered and respawn it when the Zone is exited.
  2. PresentWhenInZone: Spawn the prefab when the Zone is entered and despawn it when the Zone is exited.
  3. SpawnInZone: Spawn the prefab when the Zone is entered. Never re-spawn.
  4. DespawnInZone: Spawn the prefab when the tile’s Start method is executed; despawn it when the Zone is exited. Never re-spawn.
  5. AnimInZone: Spawn the prefab when the tile’s Start method is executed. Animation on/off when the Zone is entered/exited.
  6. AnimOutZone: Spawn the prefab when the tile’s Start method is executed and activate animation. Animation OFF on Zone entry and ON again on Zone exit.

The various state specifications change depending on which mode you select.

As you can see, some of these modes allow you to optionally start animations when the prefab is spawned. AnimInZone and AnimOutZone always require animations unless all you want to do is spawn a prefab at the tile’s position when StartUp runs; there are much simpler ways to spawn prefabs.

There’s also the option of using scriptable object plugins: TpAnimatorActions to handle animations and/or control prefab spawning for special cases; e.g., spawning a timed series of prefabs.

The base code will use the first animator that it finds via FindComponentsInChildren.

Optionally, the code won’t halt animation when the Zone is exited; rather, you can have a StateMachineBehaviour do it; use the base class AnimStateTilePingerBase as the base class for your StateMachineBehaviour.

Those interested in using this complex tile should check out the source code and this.

UI Tiles

See the UI chapter.

Event and Zone Actions and SubObjects

AnimatorAction

Animator Actions are project-level scriptable object plugins. They're only used with TpZoneAnimator tiles.

If you specify an action for one of the three sets of Actions (in the tile) it will ALWAYS be used instead of one of the specified 'StateName' fields.

The plugin get passed the tile instance. Inherit from the TpAnimatorAction class (see the example in the Layout demo).

The base class doesn't do anything and there's no asset create menu item for it.

If you specify an action for one of the three sets of Actions (in the tile) it will ALWAYS be used instead of one of the specified 'StateName' fields.

You can do whatever you want within the Action and the tile instance gives access to all the fields/properties like Target (the prefab) and PrefabAnimator.

Note that these values may be null depending on when an Action is invoked, e.g., when an ActionAtStart is used the animator may be null.

For example, if you want to use 'setfloat', 'setbool' etc: use an Action. This tile only uses the Animator.Play methods (though you can hack this code in a derived class).

If an Action spawns any prefabs and you want such prefabs to be auto-deleted when the Player moves out of the zone (ie when you use messaging to send the position to the tile and the position is outside of the zone) then add refs to these prefabs via AddSpawnedGameObject.

An Action can use its parent ZoneAnimator tile's CleanupPrefabs() to delete the prefabs; normally this is done automatically when the zone is exited OR if an AnimatorControlPacket causes a despawn (see below).

TileEventAction

These are project-level scriptable object plugins added as references to TPT tiles.

Takes an action when a TileEvent is evaluated by a controlling program. If the program uses TpEvents.ProcessEvents the Exec method in these plugins can be optionally invoked automatically. See Events.

TileZoneAction

These are similar to EventActions, but aren't automatically invoked in TilePlus. Generally the Exec method of these plugins is invoked by a TPT tile while acting on a message. See ZoneActions.

TweenerSubObject

This is a scriptable object plugins added to Event or Zone actions for adding tween capability to those plugins. See this.

UiButtonEventAction

An example Event Action for the UiButton tile that changes values on specified tiles using the UiControl interface.

ZoneActionRadio

An example Zone Acton for the UiToggleButton tile. This implements a radio-button set of toggle buttons using a Zone or a tag.

Prefabs

TPP_PoolHost

Add to a scene to use this as the parent of spawned prefabs.

TpTriggerZoneSprites

A grid-like sprite for use as sprites - handy for editing tile Zones. Use as your tile's sprite and check 'modify sprite'.