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

This tile spawns one or more prefabs and can control animation. More...

Inheritance diagram for TilePlus.TpZoneAnimator:
Collaboration diagram for TilePlus.TpZoneAnimator:

Public Types

enum  PrefabMode {
  PresentWhenNotInZone , PresentWhenInZone , SpawnInZone , DespawnInZone ,
  AnimInZone , AnimOutZone
}
 Controls how this tile manages presence of the prefab. More...

Public Member Functions

void OnEnable ()
 OnEnable event.
override bool StartUp (Vector3Int position, ITilemap tilemap, GameObject go)
virtual void OnStateChange ()
 This does the work of a state change (entering zone or leaving zone). You normally don't need to invoke this outside of this code although overriding may make sense in some situations.
virtual void Spawn (GameObject? prefab=null, Vector3? offset=null)
 Spawner.
override void CleanUp ()
 Implement to perform cleanup. RequiresCleanup
virtual void DeSpawn (bool force=false)
 Despawner.
virtual void SetId ()
 Override for different behaviour.
bool SetTarget (GameObject newTarget, Animator? newAnimator=null)
 An AnimatorAction can use this to set up the target and animator if it is doing all the spawning.
void AddSpawnedGameObject (GameObject go, bool add=true)
 An AnimatorAction can use this to add or delete spawned prefab(s) if it wants to make use of auto-despawning when zone exited. If using an ActionAtExit it can examine the property SpawnedPrefabs if it needs that info.
bool HasSpawnedGameObject (GameObject go)
 An AnimatorAction can use this to see if a spawned prefab is in the spawn list. It's more efficient than using the SpawnedPrefabs property.
void ClearSpawnedGameObjects ()
 An AnimatorAction can use this to cleanup the spawnedPrefabs list if it needs to. Note that this does not remove them from the Scene.
void CleanupPrefabs ()
 Delete any spawned prefabs in the spawnedPrefabs list. These are only added by Actions.
void Play (string stateName, int layerIndex=-1)
 Play an animation given the state name and layer index.
void Play (int stateHash, int layerIndex=-1)
 Play an animation given the state Hash and layer index.
Public Member Functions inherited from TilePlus.TilePlusBase
override bool StartUp (Vector3Int position, ITilemap tilemap, GameObject go)
 Tiles can be in three states: Asset, Clone, Locked. See the Programmer's Guide for more info. NOTE: if overriding this BE SURE to call this base method as the FIRST thing you do! Note the return value and return FALSE if this base method returns FALSE.
override void GetTileData (Vector3Int position, ITilemap tilemap, ref TileData tileData)
 Get data for this tile. Override of Tile. Note that Tilemap.RefreshTile calls this.
override string ToString ()
virtual void ResetState (TileResetOperation op)
 Used to reset state variables. May need overriding in subclasses. See programmer's guide for info on overriding this.
virtual bool UpdateInstance (string[] value)
 Default inplementation of UpdateInstance.
virtual void ActivateAnimation (bool turnOn, int startingFrame=0, bool ignoreRewindingState=false)
 Turn animation on/off for tiles which support it.
Parameters
turnOntrue/false = on/off
startingFramesets the current frame to 0 (for either operation). Use -1 to inhibit.
ignoreRewindingStateif false(default) then this method does not execute when waiting for a rewind - only when one-shot is used w/rewindAfterOneShot set true
Also see AnimationSupported property. Also, when turnOn==true, the startingFrame is set prior to starting animation. When false, the startingFrame is set after stopping the animation
virtual void PauseAnimation (bool pause)
 Pause a running animation.
Parameters
pause

virtual void LoopEndedCallback ()
 Loop-ended callback handler (originates from Tilemap component)
Public Member Functions inherited from TilePlus.ITilePlus
bool ExecEventAction (UnityEngine.Object? obj)
 Exec the event action, if any.
Public Member Functions inherited from TilePlus.ITpMessaging< in T >
void MessageTarget (T sentPacket)
 Send a message of type T.
bool CanAcceptMessage ()
 Optional "are you ready?" method that can be used in filtering prior to sending a message. Useful in some edge cases. Override in implementation if necc. NOTE this is NOT checked internally somehow. You have to use a filter and test this.

Public Attributes

int bool hasEntryHash
int bool int exitHash
PrefabMode m_PrefabMode
 Controls how the prefab is managed.
bool m_ForceSpriteClearOnStart = true
 If checked, Sprite Clear mode is forced to ClearOnStart when the tile is Enabled via OnEnable.
string m_StartUpStateName = string.Empty
 If m_PrefabMode is PresentWhenNotInZone then the prefab is spawned when the tile's Start method is entered. If a string is present in this field at Start then Play will be used on the animator with this value as a state Name.
TpAnimatorActionm_ActionAtStart
 Action at StartUp. If present, m_PlayAtStart state name is ignored.
float m_DelayAtStart = 0
 Optional delay after Start if m_PlayAtStart is not string.Empty or m_ActionAtStart != null.
string m_EntryStateName = string.Empty
 If a string is present in this field when the Zone is entered then this value is used as a state Name.
TpAnimatorActionm_ActionAtEntry
 Action at Zone Entry. If present, m_EntryStateName is ignored.
float m_DelayAtEntry = 0
 Optional delay after zone is entered.
string m_ExitStateName = string.Empty
 If a string is present in this field when the Zone is exited then this value is used as a state Name.
TpAnimatorActionm_ActionAtExit
 Action at Zone exit. If present, m_ExitStateName is ignored.
float m_DelayAtExit = 0
 Optional delay after zone is exited.
GameObject? m_Prefab
 Default behaviour is for the prefab to appear when the zone is entered and disappear when the zone is exited but you can override that in a derived class OR use a TpAnimatorAction.
Vector3 m_PrefabOffset
 This offset is applied to the prefab when spawned. Isn't used on the tile's GameObject.
bool m_UsePooling
 If the m_Prefab field is used and this is true then the prefab is pooled.
int m_PoolingPreload = 0
 If the Prefab field is used and pooling is used then this value is used for preloading. note that heavy use of this feature can induce lags as the prefabs have to be instantiated and pooled.
bool m_UseAnimatorCallback = true
 If true, use the animator callback to despawn.
bool m_IgnoreAnimator
 if true, assume prefab has no animator. In this case, only prefab spawn/despawn is managed. Note that you can use pooling and TpSpawnlink's OnTpSpawned and OnTpDespawned to control the prefab in any way you want.
float m_FinalDelay = 0
 If the AnimatorCallback is used (ie if the AnimatorCallback string param is empty) then this delay is used AFTER the callback is rcvd by this instance (MessageTarget method)
bool m_TriggerOnEntry
 Send a trigger event when the zone is entered.
bool m_TriggerOnExit
 Send a trigger event when the zone is exited.
Public Attributes inherited from TilePlus.TilePlusBase
int count
 Property to get a tuple of (count, array of individually-trimmed tags). not cached.
ColliderMode m_ColliderMode = ColliderMode.NoCollider
 Used to set up the tile's collider.
SpriteClearMode m_TileSpriteClear = SpriteClearMode.Ignore
 m_TileClear controls whether or not the tile's sprite is cleared or if the tile is deleted at runtime, or nothing.
string m_Tag = string.Empty
 The tag for this tile.
OversizeSpriteMode m_OversizeSpriteMode = OversizeSpriteMode.Ignore
 How to handle oversize sprite recognition.
Vector2 m_SpriteSize = Vector2.one
 The true size of the tile sprite. See Oversize Sprite Mode.
TpTileEventActionm_EventAction
 TpTileEventAction project asset reference. May be null.
TpTileZoneActionm_ZoneAction
 TpTileZoneAction project asset reference. May be null.
bool m_ZoneIsInUse = false
 Zone capabilities active.
Public Attributes inherited from TilePlus.ITilePlus
int count
 Property to get an array of individually-trimmed tags.

Properties

GameObject[] SpawnedPrefabs [get]
 All spawned prefabs as an array.
string Status [get]
 Status string for this tile. Don't remove even though it looks unused.
bool IsInZone [get]
 Is the last position passed-in within the described zone?
bool HasDespawnCallback [get]
 Is there an active Despawning callback on the animator?
Animator? PrefabAnimator [get]
 Prefab's Animator.
GameObject? Target [get]
 Spawned Prefab reference.
int bool int bool hasExitHash ControlHashes [get]
override bool RequiresCleanup [get]
Properties inherited from TilePlus.TilePlusBase
bool SpriteShouldBeCleared [get]
 Returns true if tile sprite should be cleared based on setting of TileSpriteClear field, tile state, and whether in Play mode or not.
byte?[] TileGuidBytes [get, set]
 The clone's GUID. Note that IDs are individual for each clone. This value can only be set once. Calling ResetState allows it to be changed until the next StartUp. If a new GUID isn't added before StartUp then that method will add it. For example: see TpLib.CopyAndPasteTile Note: generally speaking, don't reset the GUID.
string TileName [get]
TilePlusBase ThisTileInstance [get]
 Get the tile's instance thru this interface.
int Id [get]
 Id of tile. Nominally GetInstanceId. Default returns 0.
bool GetTileDataHasRun [get]
 TRUE if GetTileData has run. If this is false when TpLib.RegisterTilePlus is executed then TpLib checks to see if the tile's sprite needs to be affected. See that code for an explanation.
static Vector3Int ImpossibleGridPosition = new(int.MinValue, int.MinValue, int.MinValue) [get]
 No tile will ever be here!
Vector3Int TileGridPosition [get]
 This is the tile grid position as set from StartUp. Intentionally non-virtual. Does not need (and should not have) serialized backing field. Note that backing field is initialized to "Impossible Grid Position".
Vector3 TileWorldPosition [get]
 Handy property to get the world position from the TileGridPosition property. returns Vector3.negativeInfinity for error SO CHECK FOR THAT! note: returns cell center as world position.
Vector3Int LastTileGridPosition [get]
 Get the last tile grid position Note that backing field is initialized to "Impossible Grid Position".
Tilemap? LastParentTilemap [get]
 Get the last parent Tilemap. Note that backing firld is initialized to NULL.
bool TileGridPosHasChanged [get]
 Has the tile position changed since the last StartUp?
bool ParentTilemapHasChanged [get]
 Has the tile's parent tilemap changed since the last StartUp?
Tilemap? ParentTilemap [get]
 Parent tilemap for this tile (set in clone). Intentionally non-virtual. Does not need (and should not have) serialized backing field.
int ParentTilemapInstanceId [get]
 The instance ID of the parent tilemap.
bool AnimationIsPaused [get]
 Property to determine if animation is PAUSED.
virtual bool IsOneShotWaitingToRewind [get]
 Override in any animated tiles.
bool TileAnimationActive [get]
 Property to determine if animation is running in the tile. Note: running=true and paused=true is fine.
bool AnimationIsRunning [get]
 Property to determine if Tile animation is ACTIVE and not paused: IE actual animation is running.
bool IsClone [get]
 Is this a clone? Read-only.
bool IsAsset [get]
 Is this an asset? Read-only.
bool IsLocked [get]
 Is this a locked tile? Read-only.
bool IsPaletteTile [get, set]
 Valid only in-editor, is this tile from the Palette?
string TileStateString [get]
 String version of TileState.
Guid TileGuid [get]
 Get the tile's GUID as a GUID struct.
string TileGuidString [get]
 The clone's GUID as a string.
int string[] tags TrimmedTags [get]
virtual bool RequiresCleanup [get]
 If a particular tile requires special cleanup prior to deletion, EXPLICITLY implement this method and return TRUE. TpZoneAnimator
bool SanityCheck [get]
 If handling an animation callback, this is useful to ensure that the TPT tile instance is actually still attached to a Tilemap and not just transiently sitting in memory (ie deleted but not yet purged from a List or HashSet somewhere.
static TpTweener TweenerService [get]
 GET a reference to the tweener service. It's only used by TilePlus tiles.
virtual ColliderMode TileColliderMode [get, set]
 Used to set up the tile's collider.
SpriteClearMode TileSpriteClear [get, set]
 Get the the tile sprite clear mode.
string Tag [get, set]
 Property to get the optional tag.
OversizeSpriteMode OversizeSpriteMode [get]
 This is used by the PositionDb to calculate the actual size of a sprite when determining if a position is occupied.
Vector2 SpriteSize [get]
 What is the size of the sprite? Override when implementing OversizeSpriteMode.
TpTileEventActionEventAction [get]
 A TpTileEventAction.
virtual ? object EventActionObject [get, set]
TpTileZoneActionZoneAction [get]
 A TpTileZoneAction.
BoundsInt ZoneBoundsInt [get, set]
 The BoundsInt for the zone.
Bounds ZoneBounds [get]
 A bounds based on the ZoneBoundsInt.
Properties inherited from TilePlus.ITilePlus
Scene ParentScene [get]
 Return the scene that the Tile is in. Only works on a placed tile; on a non-cloned tile it should return default Note: check the return value for Scene.IsValid.
bool IsComputeOnly [get]
 Indicate that this tile is 'compute only'.
GameObject? InstantiatedGameObject [get]
 Get the GameObject of the tile. Convenience, saves casting in editors.
bool AnimationSupported [get]
 This tile supports animation if true.

Events

Action< TpZoneAnimator >? OnZoneEnteredExited
 This event fires when there's a state change, before anything else happens. A reference to the tile is provided.

Additional Inherited Members

Protected Member Functions inherited from TilePlus.TilePlusBase
void SetColliderType (ref TileData tileData)
 Sets up colliders.
Protected Attributes inherited from TilePlus.TilePlusBase
Vector3Int m_TileGridPosition = new(int.MinValue, int.MinValue, int.MinValue)
 The tile grid position gets initialized in Startup. It's initialized with 'ImpossibleGridPosition'.
Vector3Int m_LastTileGridPosition = new(int.MinValue, int.MinValue, int.MinValue)
 The previous tile grid position.
Tilemap? m_LastParentMap
 The previous parent Tilemap.
bool m_TileGridPosHasChanged
 True if the tile grid position has changed.
bool m_ParentTilemapHasChanged
 Parent tilemap has changed if true.
Tilemap? m_ParentTilemap
 Parent tile map is initialized in Startup.
BoundsInt m_ZoneBoundsInt = new(Vector3Int.zero,new Vector3Int(3,3,1))
 BoundsInt of trigger zone. Initialized to a 3x3 area centered at the Tile's location.

Detailed Description

This tile spawns one or more prefabs and can control animation.

It DOES NOT support the use of the native tile 'gameObject'.

Note that this code only supports one animator per prefab and it'll find the first one returned by GetComponentInChildren.

Normally this is triggered via the PositionPacket message and/or the state of in-zone or out-zone.

There are four basic modes, set by the PrefabMode dropdown field: PresentWhenInZone: the prefab is spawned and animation begins when the zone is entered and despawned when exited. PresentWhenNotInZone: the prefab is spawned when the Tile's Start method is entered. Animation begins then. The prefab is despawned when the Zone is entered and re-spawned (and re-animated) when the Zone is exited. SpawnInZone: the prefab is spawned when the Zone is entered and not despawned when the zone is exited. DespawnInZone: the prefab is spawned when the Tile's Start method is entered. Animation begins then. The prefab is despawned then the Zone is entered and never re-spawned.

Note that if you use state names then the animator layer isn't used. If you want to use layers with the animator use an ActionAtStart, ActionAtExit, or ActionAtEntry.

Actions are project-level scriptable obj instances of TpAnimatorAction which get passed the tile instance. Inherit from the TpAnimatorAction abstract class (see the example in the Layout demo). 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 CleanupPrefabs() to delete the prefabs; normally this is done automatically when the zone is exited OR if an AnimatorControlPacket causes a despawn (see below).

As your Player is moving, send PositionPacket messages to an instance of this tile and the tile will check to see if it is within the zone or outside of it and spawn or despawn the prefab and start/stop animation.

You can also use Tile+ messaging to send an AnimatorControlPacket to this tile in order to activate an animation using Play(string stateName, int layer = -1, float normalizedTime = float.NegativeInfinity); (Use 'StringPacket') or Play(int stateNameHash, int layer = -1, float normalizedTime = float.NegativeInfinity); (Use 'IntPacketIn')

The AnimatorControlPacket can also specify that the prefab should be despawned. This is normally used by an Animator StateMachineBehaviour. An example of this is shown in the TopDownDemo where the StateMachineBehaviour 'AnimStateTilePingerBase' is used to send such a packet to this tile. The animator state machine has a field where the GUID of the tile instance is poked by this tile's overridable SetId method. Hence, the behaviour can send a message to the tile by looking up the tile using TpLib.GetTilePlusBaseFromGuid(). Handy!

Use this tile's m_UseAnimatorCallback field to specify that this scheme should be used. If that's true but there are no instances of AnimStateTilePingerBase or subclasses thereof then a warning message is sent to the console.

To use this tile: add a project-asset prefab reference to the m_Prefab field in the project or via Tile+Painter in Edit mode. – Note that you can still use the tile's gameObject field but this code will ignore it. – Note that the prefab will have TpSpawnLink added to it if not already present. – Note: if there's no exit action or hash then the prefab is destroyed OR restored to pool when the zone is exited. Otherwise the animation should have an event of some sort to destroy the prefab - this code can't handle that automatically due to the difficulty of ensuring that the animation is totally complete.

Member Enumeration Documentation

◆ PrefabMode

Controls how this tile manages presence of the prefab.

Enumerator
PresentWhenNotInZone 

Spawn at Start, despawn on Zone entry, respawn on Zone exit Note that m_PlayAtStart, m_ActionAtStart, and m_DelayAtStart affect what happens at Start but the 'Entry' parameters are used when respawning on Zone exit.

PresentWhenInZone 

Spawn at Zone entry and despawn at Zone exit. m_PlayAtStart, m_ActionAtStart, and m_DelayAtStart at NOT used.

SpawnInZone 

Spawn at Zone entry, never despawn.

DespawnInZone 

Spawn at Start, Despawn on Zone Entry, never re-spawn.

AnimInZone 

Spawn at Start, never despawn. Animation on/off on Zone enter/exit.

AnimOutZone 

Spawn at Start, animation on, never despawn. Animation OFF on Zone enter, ON on Zoneexit.

Member Function Documentation

◆ AddSpawnedGameObject()

void TilePlus.TpZoneAnimator.AddSpawnedGameObject ( GameObject go,
bool add = true )

An AnimatorAction can use this to add or delete spawned prefab(s) if it wants to make use of auto-despawning when zone exited. If using an ActionAtExit it can examine the property SpawnedPrefabs if it needs that info.

Parameters
goGameObj to add/delete
addif true is add

if the go is the same as target it's ignored.

◆ CleanUp()

override void TilePlus.TpZoneAnimator.CleanUp ( )
virtual

Implement to perform cleanup. RequiresCleanup

Reimplemented from TilePlus.TilePlusBase.

◆ CleanupPrefabs()

void TilePlus.TpZoneAnimator.CleanupPrefabs ( )

Delete any spawned prefabs in the spawnedPrefabs list. These are only added by Actions.

◆ ClearSpawnedGameObjects()

void TilePlus.TpZoneAnimator.ClearSpawnedGameObjects ( )

An AnimatorAction can use this to cleanup the spawnedPrefabs list if it needs to. Note that this does not remove them from the Scene.

CleanupPrefabs

◆ DeSpawn()

virtual void TilePlus.TpZoneAnimator.DeSpawn ( bool force = false)
virtual

Despawner.

◆ HasSpawnedGameObject()

bool TilePlus.TpZoneAnimator.HasSpawnedGameObject ( GameObject go)

An AnimatorAction can use this to see if a spawned prefab is in the spawn list. It's more efficient than using the SpawnedPrefabs property.

Parameters
goGO to test
Returns
true if in the list.

◆ OnEnable()

void TilePlus.TpZoneAnimator.OnEnable ( )

OnEnable event.

◆ OnStateChange()

virtual void TilePlus.TpZoneAnimator.OnStateChange ( )
virtual

This does the work of a state change (entering zone or leaving zone). You normally don't need to invoke this outside of this code although overriding may make sense in some situations.

◆ Play() [1/2]

void TilePlus.TpZoneAnimator.Play ( int stateHash,
int layerIndex = -1 )

Play an animation given the state Hash and layer index.

Parameters
stateHashstate name
layerIndexoptional layer index

Note that if used prior to spawning then nothing will occur. Use the PrefabAnimator and Target properties to validate.

◆ Play() [2/2]

void TilePlus.TpZoneAnimator.Play ( string stateName,
int layerIndex = -1 )

Play an animation given the state name and layer index.

Parameters
stateNamestate name
layerIndexoptional layer index

Note that if used prior to spawning then nothing will occur. Use the PrefabAnimator and Target properties to validate.

◆ SetId()

virtual void TilePlus.TpZoneAnimator.SetId ( )
virtual

Override for different behaviour.

◆ SetTarget()

bool TilePlus.TpZoneAnimator.SetTarget ( GameObject newTarget,
Animator? newAnimator = null )

An AnimatorAction can use this to set up the target and animator if it is doing all the spawning.

Parameters
newTarget
newAnimator
Returns

◆ Spawn()

virtual void TilePlus.TpZoneAnimator.Spawn ( GameObject? prefab = null,
Vector3? offset = null )
virtual

Spawner.

Parameters
prefabPrefab to spawn.
offsetNullable Vector3. An alternate offset from TileGridPosition instead of using m_PrefabOffset.

if a prefab is already spawned then this returns without doing anything. To clear this, use Despawn first or SetTarget. Note that the animator reference is always changed if a prefab is spawned.

◆ StartUp()

override bool TilePlus.TpZoneAnimator.StartUp ( Vector3Int position,
ITilemap tilemap,
GameObject go )

Member Data Documentation

◆ exitHash

int bool int TilePlus.TpZoneAnimator.exitHash

◆ hasEntryHash

int bool TilePlus.TpZoneAnimator.hasEntryHash

◆ m_ActionAtEntry

TpAnimatorAction? TilePlus.TpZoneAnimator.m_ActionAtEntry

Action at Zone Entry. If present, m_EntryStateName is ignored.

◆ m_ActionAtExit

TpAnimatorAction? TilePlus.TpZoneAnimator.m_ActionAtExit

Action at Zone exit. If present, m_ExitStateName is ignored.

◆ m_ActionAtStart

TpAnimatorAction? TilePlus.TpZoneAnimator.m_ActionAtStart

Action at StartUp. If present, m_PlayAtStart state name is ignored.

if this is used then spawning occcurs before the action is executed. That's a logical requirement so there's a target to work on.

◆ m_DelayAtEntry

float TilePlus.TpZoneAnimator.m_DelayAtEntry = 0

Optional delay after zone is entered.

◆ m_DelayAtExit

float TilePlus.TpZoneAnimator.m_DelayAtExit = 0

Optional delay after zone is exited.

◆ m_DelayAtStart

float TilePlus.TpZoneAnimator.m_DelayAtStart = 0

Optional delay after Start if m_PlayAtStart is not string.Empty or m_ActionAtStart != null.

◆ m_EntryStateName

string TilePlus.TpZoneAnimator.m_EntryStateName = string.Empty

If a string is present in this field when the Zone is entered then this value is used as a state Name.

◆ m_ExitStateName

string TilePlus.TpZoneAnimator.m_ExitStateName = string.Empty

If a string is present in this field when the Zone is exited then this value is used as a state Name.

◆ m_FinalDelay

float TilePlus.TpZoneAnimator.m_FinalDelay = 0

If the AnimatorCallback is used (ie if the AnimatorCallback string param is empty) then this delay is used AFTER the callback is rcvd by this instance (MessageTarget method)

◆ m_ForceSpriteClearOnStart

bool TilePlus.TpZoneAnimator.m_ForceSpriteClearOnStart = true

If checked, Sprite Clear mode is forced to ClearOnStart when the tile is Enabled via OnEnable.

◆ m_IgnoreAnimator

bool TilePlus.TpZoneAnimator.m_IgnoreAnimator

if true, assume prefab has no animator. In this case, only prefab spawn/despawn is managed. Note that you can use pooling and TpSpawnlink's OnTpSpawned and OnTpDespawned to control the prefab in any way you want.

◆ m_PoolingPreload

int TilePlus.TpZoneAnimator.m_PoolingPreload = 0

If the Prefab field is used and pooling is used then this value is used for preloading. note that heavy use of this feature can induce lags as the prefabs have to be instantiated and pooled.

◆ m_Prefab

GameObject? TilePlus.TpZoneAnimator.m_Prefab

Default behaviour is for the prefab to appear when the zone is entered and disappear when the zone is exited but you can override that in a derived class OR use a TpAnimatorAction.

◆ m_PrefabMode

PrefabMode TilePlus.TpZoneAnimator.m_PrefabMode

Controls how the prefab is managed.

PrefabMode

◆ m_PrefabOffset

Vector3 TilePlus.TpZoneAnimator.m_PrefabOffset

This offset is applied to the prefab when spawned. Isn't used on the tile's GameObject.

◆ m_StartUpStateName

string TilePlus.TpZoneAnimator.m_StartUpStateName = string.Empty

If m_PrefabMode is PresentWhenNotInZone then the prefab is spawned when the tile's Start method is entered. If a string is present in this field at Start then Play will be used on the animator with this value as a state Name.

◆ m_TriggerOnEntry

bool TilePlus.TpZoneAnimator.m_TriggerOnEntry

Send a trigger event when the zone is entered.

◆ m_TriggerOnExit

bool TilePlus.TpZoneAnimator.m_TriggerOnExit

Send a trigger event when the zone is exited.

◆ m_UseAnimatorCallback

bool TilePlus.TpZoneAnimator.m_UseAnimatorCallback = true

If true, use the animator callback to despawn.

◆ m_UsePooling

bool TilePlus.TpZoneAnimator.m_UsePooling

If the m_Prefab field is used and this is true then the prefab is pooled.

Property Documentation

◆ ControlHashes

int bool int bool hasExitHash TilePlus.TpZoneAnimator.ControlHashes
get

◆ HasDespawnCallback

bool TilePlus.TpZoneAnimator.HasDespawnCallback
get

Is there an active Despawning callback on the animator?

◆ IsInZone

bool TilePlus.TpZoneAnimator.IsInZone
get

Is the last position passed-in within the described zone?

◆ PrefabAnimator

Animator? TilePlus.TpZoneAnimator.PrefabAnimator
get

Prefab's Animator.

◆ RequiresCleanup

override bool TilePlus.TpZoneAnimator.RequiresCleanup
get

If a particular tile requires special cleanup prior to deletion, EXPLICITLY implement this method and return TRUE. TpZoneAnimator

This tile requires cleanup: it spawns prefabs that aren't part of a ZoneRegistration so they have to be despawned explicitly when the tile is deleted.

Implements TilePlus.ITilePlus.

◆ SpawnedPrefabs

GameObject [] TilePlus.TpZoneAnimator.SpawnedPrefabs
get

All spawned prefabs as an array.

◆ Status

string TilePlus.TpZoneAnimator.Status
get

Status string for this tile. Don't remove even though it looks unused.

◆ Target

GameObject? TilePlus.TpZoneAnimator.Target
get

Spawned Prefab reference.

Event Documentation

◆ OnZoneEnteredExited

Action<TpZoneAnimator>? TilePlus.TpZoneAnimator.OnZoneEnteredExited

This event fires when there's a state change, before anything else happens. A reference to the tile is provided.

any subscriber to this event should return ASAP; perhaps just note the state change and return and deferring the actual handling of the event later.


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