![]() |
TilePlus Version 5
Unity3D Tilemap Extension
|
This static class maintains edit-time and run-time dictionaries which track TilePlusBase items on a per-tilemap basis. In-Editor, heirarchy and tilemap changes are tracked and dictionaries are updated as necessary. More...
Static Public Member Functions | |
| static void | CloneTilePlus (TilePlusBase instance, Vector3Int position, Tilemap map, bool allowLockedTiles=false) |
| A TPT tile calls this in StartUp when cloning itself. NOT for general-purpose use. | |
| static void | RegisterTilePlus (TilePlusBase? instance, Vector3Int position, Tilemap? tilemap) |
| Tiles must call this as part of their StartUp method in order to register the tile in the various data structures. This is automatically handled in TilePlusBase so anything that inherits from that doesn't need to do anything special. | |
| static bool | RemoveTileFromDb (Tilemap? map, Vector3Int position, bool fromGroup=false) |
| Remove a tile from the database. NB - although this is public you never need to use it. This does not actually delete a tile. Use the normal Tilemap.SetTile with a null tile and the tilemap callbacks will cause the tile to be removed from the TpLib data structures. | |
| static void | AddToRefreshQueue (TilePlusBase tpb) |
| Add a tile to the set of tiles that will be refreshed at the next TpLib TpLibUpdate. See TpLib.UpdateLoop | |
| static ? Grid | GetParentGrid (Transform current) |
| Provide a Transform and this will look 'up' the heirarchy to find the parent Grid. | |
| static void | ForceOnTpLibChanged (TpLibChangeType changeType, bool isPartOfGroup, Vector3Int position, Tilemap? map) |
| Force a OnTpLibChanged event. | |
| static void | SafeDestroy (UnityEngine.Object unityObject) |
| A Safe destroy for Unity Objects. | |
| static void | SafeDeleteTile (Tilemap map, Vector3Int position) |
| A safe way for tiles to delete themselves, deletion occurs at end of frame. | |
| static void | TpLog (string logString) |
| Simpler Log for normal messages. | |
| static void | TpLogWarning (string logString) |
| Simpler Log for warning messages. | |
| static void | TpLogError (string logString) |
| Simpler log for error messages. | |
| static void | Resize (TpLibMemAlloc? m, bool rescan=true) |
| Reallocate memory sizes. | |
| static bool | IsTilemapRegistered (Tilemap? map) |
| Does a tilemap have any Tileplus tiles? | |
| static ? TilePlusBase | GetTile (Tilemap map, Vector3Int position) |
| Get a tile from the master dictionary. | |
| static ? T | GetTile< T > (Tilemap map, Vector3Int position) |
| Generic version of GetTile. | |
| static ? T | GetTileWithInterface< T > (Tilemap map, Vector3Int position) |
| Generic version of GetTile, similar to GetTile<T> but with class constraint. | |
| static bool | HasTile (Tilemap map, Vector3Int position) |
| Is there a tile at the provided position on the provided map: TilePlus tiles only! | |
| static bool | CutAndPasteTile (Tilemap map, Vector3Int currentPosition, Vector3Int newPosition, Func< Vector3Int, bool >? positionValidator=null, bool overwrite=false) |
| Cut-and-paste operation: Move a tile from currentPosition to newPosition. | |
| static bool | SwapTwoTiles (Tilemap map, Vector3Int positionA, Vector3Int positionB) |
| Swap two tileplus tiles. | |
| static bool | CopyAndPasteTile (Tilemap? destinationMap, TilePlusBase? instance, Vector3Int newPosition, Func< Vector3Int, bool >? positionValidator=null) |
| Copy and paste a tile. Makes a copy of the passed-in TPT tile instance. | |
| static bool | RemoveMap (Tilemap tilemap) |
| Delete all entries for specified Tilemap. Useful if you delete tilemaps at runtime. Note that Adding a tilemap programmatically and then adding TilePlusBase-derived tiles programatically will automatically update the DB when the tiles' StartUp method is invoked. So you do not have to add the tiles with RegisterTile or AddTileToDb. | |
| static bool | RemoveMap (int mapInstanceId) |
| Remove a single map and all tagged/typed entries. DOES NOT remove tiles, DOES NOT delete the tilemap itself See also: RemoveMap(Tilemap) | |
| static ? List< TilePlusBase > | GetAllTilePlusBaseForMap (Tilemap map) |
| Get a list of all of the TilePlusBase instances for a particular Tilemap. | |
| static ? TilePlusBase | GetTileWithIdAndType (int id, Type type, bool searchInterfaces=false) |
| Get a TilePlusBase instance given its Instance ID and Type. If searchInterfaces is true then the interfaces dictionary is examined. | |
| static void | GetAllTilesInRegionForMap (Tilemap map, List< TilePlusBase > output, RectInt region) |
| Get all TilePlus tiles in a region. | |
| static void | GetAllTiles< T > (List< T >? output, Func< T, TilePlusBase, bool >? filter=null) |
| Place all tiles of Type T (not interfaces!) in all tilemaps into the output list. | |
| static void | GetAllTilesOfType (Tilemap? map, Type? matchThis, List< TilePlusBase >? output, Func< TilePlusBase, bool >? filter=null, RectInt? region=null, bool includeSubclasses=false) |
| Get all tiles of a particular type from a specified tilemap. Optional filter Func delegate for pre-filtering of results. Normally excludes subclasses unless includeSubclasses is TRUE. | |
| static int | NumTilesWithInterface< T > (Func< TilePlusBase, NumTileWithInterfaceFilterResult >? filter=null) |
| Are there any tiles with the specified interface? Most useful with the filter. For example, if the filter tests TilePlusBase.TileGridPosition one can filter for 'is there any tile at this position with this interface'. | |
| static void | GetAllTilesWithInterface< T > (List< TilePlusBase >? output, Tilemap? map=null, Type? matchThisTileType=null, Func< TilePlusBase, bool >? filter=null, bool includeSubclasses=false) |
| Get all tiles from a particular tilemap, optionally filtered for a tile class type, but always filtered for a particular interface being implemented. Optional pre-filtering of results. | |
| static void | GetAllTilesWithInterfaceOfT< T > (List< T >? output, Func< T, TilePlusBase, bool >? filter=null, RectInt? region=null) |
| Get all tiles with an interface of type T from all Maps. Optional prefilter delegate. | |
| static void | GetAllTagsUsedByTileType (Type tileType, HashSet< string >? tags) |
| Populate a HashSet<string> with all tags used by a tile Type. | |
| static void | GetTilesWithTag (Tilemap? map, string tag, List< TilePlusBase >? output, Func< TilePlusBase, bool >? filter=null, RectInt? region=null) |
| Get all tiles with a particular Tag. Optional prefilter. | |
| static TilePlusBase | GetFirstTileWithTag (Tilemap? map, string tag) |
| Get the first tile with a particular tag. | |
| static void | GetAllTypesInDb (List< Type >? output, bool includeBase=false, bool getNonTilePlusTypes=false) |
| Get all Types in the DB. | |
| static bool | HasGuid (Guid guid) |
| Is a tile with a GUID already in the DB? | |
| static ? TilePlusBase | GetTilePlusBaseFromGuid (byte[] guid, bool extendedSearch=true) |
| Get the TilePlusBase that's refenced by a GUID byte array. | |
| static ? TilePlusBase | GetTilePlusBaseFromGuid (string guid, bool extendedSearch=true) |
| Get the TilePlusBase that's referenced by a GUID string. | |
| static ? T | GetTilePlusBaseOfTypeFromGuid< T > (string guid, bool extendedSearch=true) |
| Get the TilePlusBase that's referenced by a GUID string. | |
| static ? T | GetTilePlusBaseOfTypeFromGuid< T > (Guid guid, bool extendedSearch=true) |
| Get the TilePlusBase that's refenced by a GUID struct. | |
| static ? TilePlusBase | GetTilePlusBaseFromGuid (Guid guid, bool extendedSearch=true) |
| Get the TilePlusBase that's refenced by a GUID struct. | |
| static void | GetAllPositionsForMap (Tilemap? map, HashSet< Vector3Int >? output, bool includeUnityTiles=true, bool clearOutput=true) |
| Get a HashSet of Vector3Ints representing all occupied positions on a tilemap. | |
| static bool | IsTilemapLocked (Tilemap? map) |
| Is the specified map Locked? Note that this will return true if there are any locked tilemaps in the same scene. | |
| static bool | IsTilemapLocked (int mapId) |
| Is the specified map Locked? | |
| static bool | IsTilemapRegistered (int mapId) |
| Is the specified map 'registered' ie is it being monitored because it has TPT tile? | |
| static ? Tilemap | FindTilemap (string tilemapName) |
| Find a tilemap by name. Not just those with TPT tiles. | |
| static ? Tilemap | FindTilemap (int instanceId) |
| Find a tilemap by InstanceId. Not just those with TPT tiles. | |
| static ? Transform | FindTilemapTransform (string tilemapName) |
| Find a tilemap transform by name. Not just those with TPT tiles. | |
| static void | SceneScan () |
| Scan all scenes including complete scan of all scenes and their Tilemaps. | |
| static void | SceneScan (List< Tilemap >? maps, bool cleanState=true) |
| Scans all scenes, gets all tilemaps, populate database. | |
| static List< Scene > | GetAllScenes (bool ignorePrefabStages=false) |
| Get a list of all scenes. | |
| static bool | GetTilemapsInScene (Scene aScene, List< Tilemap >? tilemapsList, bool includeNonTptMaps=false) |
| Get all tilemaps in the scene. Optional filtering. | |
| static ulong | DelayedCallback (Object? parent, Action? callback, string info, float delayInSeconds=0f, bool silent=false, Func< float, bool >? condition=null, bool testConditionFirst=false) |
| Execute a simple callback after a delay in seconds. | |
| static ulong | InvokeRepeatingUntil (Object parent, string info, Func< float, bool > invokedFunc, float repeatInterval=0f, bool silent=true) |
| Invoke a Func<float,bool> repeatedly. Convenience method for DelayedCallback use as timer. | |
| static bool | HasCallbackForId (ulong id) |
| Is there an active callback for this ID? | |
| static bool | KillCallback (ulong id) |
| Kill a pending callback (including those started by InvokeRepeating, although usually you kill those by returning false from that method's invoked callback). | |
| static bool | HasCallbackForObject (Object obj) |
| Is there a callback already set up for a UnityEngine.Object? | |
| static bool | KillAllCallbacksForObject (Object obj) |
| Kills any active delayed callbacks for a UnityEngine.Object. | |
| static double double requeueTime | StartAndRequeueTimeForId (ulong id) |
| static async Awaitable< bool > | WhenAll (List< Awaitable< bool > > awaitables) |
| Helper method to have WaitAll for Awaitable<bool>. | |
| static async Awaitable | WhenAll (List< Awaitable > awaitables) |
| Helper method to have WaitAll for Awaitable. | |
Static Public Attributes | |
| const int | PaletteTilemapLayer = 31 |
| A constant that is the same as the Palette tilemap layer. | |
| const int | TilemapAndTagDictsInitSize = 128 |
| The initialization size for certain dicts. | |
| const int | GuidDictInitialSize = 64 |
| The initialization size for the GUID-to-tile Dictionary. | |
| const int | TypesInitSize = 16 |
| The initialization size for certain dicts. | |
| const int | PoolNewItemSize_Dict_V3I_Tpb = 4 |
| Size of Dictionaries (Vector3Int=to=TilePlusBase) when new ones are created in the pool. | |
| const int | PoolNewItemSize_List_Tpb = 8 |
| Size of Lists of TilePlusBase when new ones are created in the pool. | |
| const string | ReservedTag = "------" |
| This tag can't be used by users. | |
| const uint | MaxDeferredCallbackInitialValue = 32 |
| Initial value for maximum number of deferred callbacks per update. | |
| const uint | MaxClonesInitialValue = 32 |
| Initial value for maximum number of Clonings per update. | |
| static double | startTime |
| Get the Start and Requeue times for an ID. | |
| static ? Func< bool > | S_OnResetPlayerLoop |
| Callback for optional custom takedown of player loop. Occurs before any effect on PlayerLoop. If Func returns true then it's assumed that the Func did it's own work and no other action is needed. If it returns false then the PlayerLoop is set to the default Unity player loop (which would overwrite any actions taken in the Func).. | |
Properties | |
| static bool | IsPlayMode [get] |
| In-Editor, returns true if EditorApplication.isPlayingOrWillChangePlaymode is true. In a built app this always returns true. One would expect the compiler to removed this method when it optimizes in an non-editor build. | |
| static bool | IsSceneScanActive [get] |
| Property to determine if a scene scan is in progress. | |
| static bool | InhibitOnTpLibChanged [get, set] |
| Inhibits OnTpLibChangedEvents: | |
| static bool | InhibitTilemapCallbacks [get, set] |
| Inhibits tilemap callbacks (OnTilemapPositionChanged, OntilemapTileChanged). Useful if you're doing a lot of Tilemap operations but don't want the system to handle these callbacks. Note that the internal DBs of TpLib will be incorrect; use SceneScan afterwards. That's not automatic!! The effect of this property isn't the same as InhibitOnTpLibChanged which just inhibits the callback. InhibitTilemapCallbacks causes the tilemap callbacks (OnTilemapPositionChanged, OntilemapTileChanged) to immediately return. | |
| static bool | TpLibIsInitialized [get] |
| Returns true if the TpLib is ready to access. Cloning queue is examined to ensure no delayed registrations. | |
| static int | TilemapsCount [get] |
| How many tilemaps are being tracked. | |
| static ? Dictionary< Guid, TilePlusBase > | OptionalGuidToTileMapping [get, set] |
| Allows accessing the optional Guid maps. See GetTilePlusBaseFromGuid variants. | |
| static int | TaggedTilesCount [get] |
| Number of different tags. | |
| static int | TileTypesCount [get] |
| Number of different Types. | |
| static int | TileInterfacesCount [get] |
| Number of interfaces. | |
| static int | GuidToTileCount [get] |
| Number of GUIDs. | |
| static IEnumerable< string > | GetAllTagsInDb [get] |
| Get all tags. | |
| static Dictionary< Guid, TilePlusBase >.ValueCollection | GetAllTilesRaw [get] |
| Get all tiles. Note: uses GuidToTile dictionary's Values. | |
| static List< Vector3Int > | NonTppTilesAddedOrModified [get] |
| A list of non tileplus tiles that were added or modified. | |
| static int | CurrentActiveDelayedCallbacks [get] |
| How many active delayed callbacks. | |
| static int | CloneQueueMaxDepth [get] |
| For statistics. Observable in SysInfo window. | |
| static int | CloneQueueDepth [get] |
| For statistics. Observable in SysInfo window. | |
| static int | RefreshQueueDepth [get] |
| For statistics. Observable in SysInfo window. | |
| static bool | CloneOrRefreshBusy [get] |
| True if tiles are waiting to clone or refresh. | |
| static int | RefreshQueueMaxDepth [get] |
| For statistics. Observable in SysInfo window. | |
| static int | RefreshQueuePerUpdate = 32 [get] |
| For statistics. Observable in SysInfo window. | |
| static float | FrameRate [get] |
| publicly-accesssible frame rate. | |
| static int | WorstFrameRate = 500000 [get] |
| Worst frame rate for current Run session. | |
| static int | BestFrameRate = 0 [get] |
| Best frame rate for current Run session. | |
| static float | TargetFrameRate = 60 [get, set] |
| Target frame rate for current Run session. | |
| static bool | TargetFrameRateMet [get] |
| Is the target frame rate met? | |
| static bool | UsingPlayerLoop [get] |
| Is the Tp update pump using the Player loop? | |
| static int | DeferredQueueMaxDepth [get] |
| For statistics. Observable in SysInfo window. | |
| static int | LargestSyncTileCount [get] |
| For statistics. Observable in SysInfo window. | |
| static int | LargestPosChangedCount [get] |
| For statistics. Observable in SysInfo window. | |
| static int | DeferredQueueDepth [get] |
| For statistics. Observable in SysInfo window. | |
| static uint | MaxNumClonesPerUpdate [get, set] |
| Set the maximum number of tile clones that can occur on one TpLibUpdate. Note that if you set this to zero or LT 0 then the value used is uint.maxvalue which is a pretty big number. This value should be relatively small, but the exact value is app-dependent. If you never place TPT tiles in a running game then this can be ignored. A too-small value will increase the delay from when a TPT tile is painted to when it is cloned. That can affect the appearance of animated tiles. | |
| static uint | MaxNumDeferredCallbacksPerUpdate [get, set] |
| Set the maximum number of deferred callbacks that can occur on one TpLibUpdate. Note that if you set this to zero or LT 0 then the value used is long.maxvalue which is a pretty big number. This value should be relatively small, but the exact value is app-dependent. | |
| static ? TpLibMemAlloc | MemAllocSettings [get] |
| Get the current memory allocation settings for TpLib. | |
| static string | VersionInformation [get] |
| Get a string with Name, Version, Build Timestamp. | |
| static string | ShortVersionInformation [get] |
| Get a string with abbreviated version information. | |
| static bool | FrameRateFail [get] |
| Set true when frame rate is lower than the target. | |
| static List< string > | GetDelayedCallbackStates [get] |
| Get a list of all ToString from the delayed callbacks. Not for use in an update loop @ runtime aside from debugging. Used by SystemInfo window's Dump button. | |
| static bool | PauseTpLibUpdate [get, set] |
| Set this TRUE to stop all updating in TpLibUpdate. This stops all tweening, callbacks, tile cloning, etc. | |
| static bool | UpdateLoopRunning [get] |
| True if the internal update loop is running. | |
| static ulong | UpdateLoopCount [get] |
| TpLibUpdate loop count, for diags. | |
Events | |
| static ? Action< TpLibChangeType, bool, Vector3Int, Tilemap?> | OnTpLibChanged |
| Event when the TpLib changes due to an addition or deletion. NOTE that this event is NOT cleared when a scene loads or unloads, so if you have anything that could be deleted on a scene (un)load, be sure to use OnEnable and OnDisable to add and remove your callback target. ChangeType, bool is false for single tiles, true if this is part of a group of changes, Position, map. | |
| static ? Action< Tilemap, Tilemap.SyncTile[]> | OnTilemapTileChangedHook |
| If you want to subscribe to Tilemap.tilemapTileChanged use this event instead. The handler for this event in TpLib will also invoke these; its more efficient. Note that this is not always invoked, see if it is appropriate for your use. Note: don't use for monobehaviours or tiles. | |
| static ? Action< Tilemap, NativeArray< Vector3Int > > | OnTilemapPositionsChangedHook |
| If you want to subscribe to Tilemap.tilemapPositionsChanged use this event instead. The handler for this event in TpLib will also invoke these; its more efficient. Note that this is not always invoked, see if it is appropriate for your use. Note: don't use for monobehaviours or tiles. | |
This static class maintains edit-time and run-time dictionaries which track TilePlusBase items on a per-tilemap basis. In-Editor, heirarchy and tilemap changes are tracked and dictionaries are updated as necessary.
It would be a bad idea to change anything in this class.
|
static |
Add a tile to the set of tiles that will be refreshed at the next TpLib TpLibUpdate. See TpLib.UpdateLoop
| tpb |
|
static |
A TPT tile calls this in StartUp when cloning itself. NOT for general-purpose use.
| instance | TilePlusBase instance |
| position | current tile position |
| map | current tile's parent Tilemap |
| allowLockedTiles | clone a locked tile if true. Normally false. |
The clone 'requests' are put into a Queue and execute on the next EditorUpdate (not playing, in Editor) or on the text tick of the 'pump' (see TpLibTasks). When an item is taken out of the Queue the tile is cloned. If at that time the Tilemap or TPB instance values saved in the CloningData class instance removed from the queen turn out to be null then no action is taken and the tile isn't cloned. And yet another note about runtime use: many tiles painted at once will enlarge the queue and when the next TpLibUpdate occurs all of the Cloning will be done at once. If that's an issue, use the MaxNumClonesPerUpdate property to non-zero (zero indicates do all of them).
|
static |
Copy and paste a tile. Makes a copy of the passed-in TPT tile instance.
| destinationMap | tilemap to paste the tile |
| instance | tile to copy and paste |
| newPosition | the position. Note if there's a tile there then nothing happens and the return value is false. |
| positionValidator | Func that accepts a Vector3Int position and returns a bool. Can be used to test if the move position is OK. |
|
static |
Cut-and-paste operation: Move a tile from currentPosition to newPosition.
| map | The tilemap |
| currentPosition | The current position |
| newPosition | The new position |
| positionValidator | Func that accepts a Vector3Int position and returns a bool. Can be used to test if the move position is OK. |
| overwrite | Overwrite new positions if true, if false, will not overwrite. |
Cut/Paste from one tilemap to another isn't supported.
|
static |
Execute a simple callback after a delay in seconds.
| parent | Parent UnityEngine.Object. If non-null, checks for null before callback invoked. |
| callback | Callback |
| delayInSeconds | delay before callback is excuted in seconds e.g., 0.5f is 500 msec. Note that a negative delay is changed to 0 and an optional warning is printed to the console |
| info | Info string for logs |
| silent | if true, no messages except errors |
| condition | a Func sent Time.deltaTime (float) returning bool. If this func returns false then the delayed callback is placed back in the deferred queue. |
| testConditionFirst | If true, the condition is tested before the duration. Use to have a condition with a max timeout. |
ID of the callback. Can use this to kill the callback without execing the callback method. Note that a return value of 0 is an error indication.
If delayInSeconds is omitted, the default is 0 sec, so the next pass thru the UpdateLoop (in TpLibTasks) will cause the callback to be invoked. Note that this is different: in an built app or Editor-Play mode it's an internal update loop that's synchronized with ENDOFFRAME (Awaitable-based pump) or POSTLATEUPDATE (Player loop mode). In Editor-edit mode it's in time with EditorApplication.update. This is VERY useful for trivial delays like when you want to call some method from an within a tile's initialization (see TilePlusBase) or from within OnGUI or the like eg from IMGUI code: situations where many sorts of ordinary things you'd like to do will cause beaucoup errors or crash the Editor.
NOTE: this is not intended to be used in a loop where this method is entered very frequently.
|
static |
Find a tilemap by InstanceId. Not just those with TPT tiles.
| instanceId | name of tilemap to search for |
|
static |
Find a tilemap by name. Not just those with TPT tiles.
| tilemapName | name of tilemap to search for |
|
static |
Find a tilemap transform by name. Not just those with TPT tiles.
| tilemapName | name of tilemap to search for |
|
static |
Force a OnTpLibChanged event.
This can be used when you're doing a bulk operation that affects a lot of tiles. That avoids many change events. Use InhibitOnTpLibChanged=true, then false, then this method.
| changeType | A value from the TpLibChangeType enum |
| isPartOfGroup | true if this is part of a group of changes |
| position | position, if appropriate |
| map | Tilemap (can be null) |
|
static |
Get a HashSet of Vector3Ints representing all occupied positions on a tilemap.
| map | The tilemap to use |
| output | HashSet for output. Note is cleared unless clearOutput is false |
| includeUnityTiles | report on Unity tiles as well (slower) |
| clearOutput | Clear the HashSet if true (default) |
Map.CompressBounds is used when includeUnityTiles=true
|
static |
Get a list of all scenes.
| ignorePrefabStages | Set true to ignore prefab stages |
NOTE that the returned list is the SAME list for each method call, so use care.
|
static |
Populate a HashSet<string> with all tags used by a tile Type.
| tileType | the Type of tile |
| tags | HashSet<string> Cleared before use. |
Tags are modified with Trim() to remove leading and trailing spaces.
|
static |
Get a list of all of the TilePlusBase instances for a particular Tilemap.
| map | The Tilemap |
|
static |
Place all tiles of Type T (not interfaces!) in all tilemaps into the output list.
| output | results list. Is cleared. If list is null it's an error |
| filter | Optional delegate for filtering, Func with an instance of Type T and a TilePlusBase - returns bool |
| T | Type is TilePlusBase or subclasses. NOT interfaces! |
Will only find the exact type specified by the TypeParam, not super or subclasses.
| T | : | TilePlusBase |
|
static |
Get all TilePlus tiles in a region.
| map | Tilemap |
| output | provide an output list. List IS NOT CLEARED BEFORE USE! |
| region | provide a region |
|
static |
Get all tiles of a particular type from a specified tilemap. Optional filter Func delegate for pre-filtering of results. Normally excludes subclasses unless includeSubclasses is TRUE.
| map | a tilemap reference. If map==null, then all tiles of Type are returned regardless of map. |
| matchThis | A type, usually from Typeof() but could be GetType(). NOTE: if this is null then ALL tile instances are returned |
| output | A List for the output. Is Cleared. Error if null. |
| filter | Optional delegate for filtering |
| region | Optional prefilter, if !null position must be contained in the RectInt. |
| includeSubclasses | if true and if matchThis != null then if the tile type isn't located directly, search for tiles that are a subclass of matchThis |
faster without map specification or filter delegate. If nothing is found then the list will be empty
|
static |
Get all tiles from a particular tilemap, optionally filtered for a tile class type, but always filtered for a particular interface being implemented. Optional pre-filtering of results.
| T |
| output | List<TilePlusBase>. Is Cleared. if null is error. |
| map | a Tilemap reference. If null, then use all tilemaps |
| matchThisTileType | Optional prefilter for a particular tile Type. If null, all tiles are examined in one map (map!=null) or all maps (map==null). |
| filter | Optional results filter. |
| includeSubclasses | if matchThisTileType != null and this is true then subclasses are examined as well |
The T is the interface. The list 'output' will be empty if nothing is found.
|
static |
Get all tiles with an interface of type T from all Maps. Optional prefilter delegate.
This is the best choice for most uses. The filter delegate is like (T,tpb)=> bool func – using the param available by the interface type T or the TilePlusBase tpb.
| output | List of type T. Is Cleared or, if null is error. |
| T | Type of the interface desired |
| filter | Optional results filter. |
| region | Optional region, applied before filter. |
|
static |
Get all Types in the DB.
| output | list of Types |
| includeBase | include tileplusbase type in output |
| getNonTilePlusTypes | Get all types from TileBase on up. Note: much slower since all open scenes and tilemaps are scanned. |
|
static |
Get the first tile with a particular tag.
| map | map to check, can be null (note is faster if map is null) |
| tag | tag to look for |
|
static |
Provide a Transform and this will look 'up' the heirarchy to find the parent Grid.
| current | the starting point |
|
static |
Get a tile from the master dictionary.
| map | which tilemap |
| position | grid position |
|
static |
Generic version of GetTile.
| map | which tilemap |
| position | grid position |
| T | Type parameter, must be TilePlusBase or subclass |
To have T as an interface, use GetTileWithInterface
| T | : | TilePlusBase |
|
static |
Get all tilemaps in the scene. Optional filtering.
| aScene | A scene to test |
| tilemapsList | pre-allocated List of tilemaps. |
| includeNonTptMaps | if true include maps with no TPT tiles. |
Note that tilemapsList isn't cleared: intentional
|
static |
Get the TilePlusBase that's refenced by a GUID byte array.
| guid | The GUID byte array |
///
| extendedSearch | true (default) use the ZoneManager and/or s_OptionalGuidToTileMappings to try and find the TPT tile from the guid. if the primary lookup fails. |
extendedSearch param should be set false for improved efficiency when using Chunkified TileBundles ie when using the ChunkZoneSelector.
|
static |
Get the TilePlusBase that's refenced by a GUID struct.
| guid | Guid struct |
| extendedSearch | true (default) use the ZoneManager and/or s_OptionalGuidToTileMappings to try and find the TPT tile from the guid. if the primary lookup fails. |
extendedSearch param should be set false for improved efficiency when using Chunkified TileBundles ie when using the ChunkZoneSelector.
|
static |
Get the TilePlusBase that's referenced by a GUID string.
| guid | Guid string |
| extendedSearch | true (default) use the ZoneManager and/or s_OptionalGuidToTileMappings to try and find the TPT tile from the guid. if the primary lookup fails. |
extendedSearch param should be set false for improved efficiency when using Chunkified TileBundles ie when using the ChunkZoneSelector.
|
static |
Get the TilePlusBase that's refenced by a GUID struct.
| guid | Guid struct |
| extendedSearch | true (default) use the ZoneManager and/or s_OptionalGuidToTileMappings to try and find the TPT tile from the guid. if the primary lookup fails. |
extendedSearch param should be set false for improved efficiency when using Chunkified TileBundles ie when using the ChunkZoneSelector.
| T | : | TilePlusBase |
|
static |
Get the TilePlusBase that's referenced by a GUID string.
| guid | Guid string |
| extendedSearch | true (default) use the ZoneManager and/or s_OptionalGuidToTileMappings to try and find the TPT tile from the guid. if the primary lookup fails. |
extendedSearch param should be set false for improved efficiency when using Chunkified TileBundles ie when using the ChunkZoneSelector.
| T | : | TilePlusBase |
|
static |
Get all tiles with a particular Tag. Optional prefilter.
| map | a Tilemap reference, if null, search all Tilemaps w TilePlus tiles. |
| tag | the tag to search for |
| output | a List<TilePlusBase> - if list is null is an error otherwise list is cleared |
| filter | Optional prefilter |
| region | Optional prefilter, if !null position must be contained in the RectInt. |
list is empty if no tiles found.
|
static |
Get a TilePlusBase instance given its Instance ID and Type. If searchInterfaces is true then the interfaces dictionary is examined.
| id | instance ID to search for |
| type | tile's Type from typeof operator |
| searchInterfaces | If this is true, search the Interfaces dictionary |
|
static |
Generic version of GetTile, similar to GetTile<T> but with class constraint.
| map | which tilemap |
| position | grid position |
| T | Type parameter, must be class (or commonly, an interface). |
| T | : | class |
|
static |
Is there an active callback for this ID?
| id | callback ID |
|
static |
Is there a callback already set up for a UnityEngine.Object?
| obj | UnityEngine.Object |
|
static |
Is a tile with a GUID already in the DB?
| guid | a GUID |
Used primarily by TilePlusBase code to determine if a TilePlusBase instance is already registered
|
static |
Is there a tile at the provided position on the provided map: TilePlus tiles only!
| map | tilemap to look at |
| position | position to examine |
true if the specified map has tile; otherwise, false.
|
static |
Invoke a Func<float,bool> repeatedly. Convenience method for DelayedCallback use as timer.
| parent | parent Object. Cannot be null |
| info | Info string for debugging |
| repeatInterval | interval between calls to invokedFunc |
| invokedFunc | a Func<float,bool> See remarks |
| silent | no console messages if true (default) |
See also DelayedCallback
The invokedFunc takes a float (delta time) and returns a bool. If the returned value is true then the repeated invokes stop. IE return false as long as you want the invokes to continue. One can also use KillCallback to terminate.
|
static |
Is the specified map Locked?
| mapId | a tilemap instance ID |
|
static |
Is the specified map Locked? Note that this will return true if there are any locked tilemaps in the same scene.
| map | a tilemap |
|
static |
Is the specified map 'registered' ie is it being monitored because it has TPT tile?
| mapId | a tilemap instance Id |
|
static |
Does a tilemap have any Tileplus tiles?
| map | The map. |
true if [is tilemap registered] [the specified map]; otherwise, false.
|
static |
Kills any active delayed callbacks for a UnityEngine.Object.
| obj | UnityEngine.Object |
Not for frequent use: creates garbage
|
static |
Kill a pending callback (including those started by InvokeRepeating, although usually you kill those by returning false from that method's invoked callback).
| id | the ID returned by DelayedCallback. |
|
static |
Are there any tiles with the specified interface? Most useful with the filter. For example, if the filter tests TilePlusBase.TileGridPosition one can filter for 'is there any tile at this position with this interface'.
| filter | optional filter |
| T | Interface type. NOT tile type |
The filter accepts a TilePlusBase instance and returns a value from the NumTileWithInterfaceFilterResult enum. Use PassAndQuit if the method should exit after the filter test. This can be used to avoid counting the exact number of matching tiles if all you care about is that at least one was found.
|
static |
Tiles must call this as part of their StartUp method in order to register the tile in the various data structures. This is automatically handled in TilePlusBase so anything that inherits from that doesn't need to do anything special.
| instance | The tile plus base instance. |
| position | The tile position |
| tilemap | The tile's parent tilemap |
Note that Adding a tilemap programmatically and then adding TilePlusBase-derived tiles programatically will automatically update the DB when the tiles' StartUp method is invoked.
|
static |
Remove a single map and all tagged/typed entries. DOES NOT remove tiles, DOES NOT delete the tilemap itself See also: RemoveMap(Tilemap)
| mapInstanceId | the instance ID of the map to remove |
true if XXXX, false otherwise.
|
static |
Delete all entries for specified Tilemap. Useful if you delete tilemaps at runtime. Note that Adding a tilemap programmatically and then adding TilePlusBase-derived tiles programatically will automatically update the DB when the tiles' StartUp method is invoked. So you do not have to add the tiles with RegisterTile or AddTileToDb.
| tilemap | The tilemap. |
IMPORTANT: DOES NOT DELETE A TILEMAP, USE BEFORE YOU DELETE THE TILEMAP.
|
static |
Remove a tile from the database. NB - although this is public you never need to use it. This does not actually delete a tile. Use the normal Tilemap.SetTile with a null tile and the tilemap callbacks will cause the tile to be removed from the TpLib data structures.
| map | What map is it on? |
| position | what's its position? |
| fromGroup | Set true if you're deleting this tile as one of a group of deletions. This parameter is not used at runtime |
|
static |
Reallocate memory sizes.
| m | an instance of TpLibMemAlloc |
| rescan | call TpLib.SceneScan after reallocation. This is generally required since reallocation wipes out all of the stored TilePlus tile data. |
This should be done immediately/soon after startup. Intended for runtime use only. Use in editor mode isn't useful since each scripting reload would wipe this out. Also, statically-declared lists and dictionaries won't be resized below their current size. Also, CleanState is used to release pooled items. Note that doing so resets MaxNumClonesPerUpdate and MaxNumDeferredCallbacksPerUpdate to their initial values.
|
static |
A safe way for tiles to delete themselves, deletion occurs at end of frame.
| map | Tilemap |
| position | Position. |
See 'TreasureChestTile' from the Layout demo for an example.
|
static |
A Safe destroy for Unity Objects.
| unityObject | Object to destroy |
Handles in-editor and play-mode correctly
|
static |
Scan all scenes including complete scan of all scenes and their Tilemaps.
|
static |
Scans all scenes, gets all tilemaps, populate database.
| maps | Optional tilemaps list. If provided, scenes not scanned nor state cleaned. |
| cleanState | execute CleanState (default=true) |
Clears the database if tilemaps list not provided.
|
static |
|
static |
Swap two tileplus tiles.
| map | Tilemap (must be the same for both tiles) |
| positionA | Tile Position A |
| positionB | Tile Position B |
|
static |
Simpler Log for normal messages.
| logString | text to add to the log |
|
static |
Simpler log for error messages.
| logString | text to add to the log |
|
static |
Simpler Log for warning messages.
| logString | text to add to the log |
|
static |
Helper method to have WaitAll for Awaitable.
| awaitables |
H/T https://github.com/timo-sisus/awaitable-utility/blob/main/AwaitableUtility.
|
static |
Helper method to have WaitAll for Awaitable<bool>.
| awaitables |
H/T https://github.com/timo-sisus/awaitable-utility/blob/main/AwaitableUtility. Modified for Awaitable<bool>
|
static |
The initialization size for the GUID-to-tile Dictionary.
|
static |
Initial value for maximum number of Clonings per update.
|
static |
Initial value for maximum number of deferred callbacks per update.
|
static |
A constant that is the same as the Palette tilemap layer.
|
static |
Size of Dictionaries (Vector3Int=to=TilePlusBase) when new ones are created in the pool.
|
static |
Size of Lists of TilePlusBase when new ones are created in the pool.
|
static |
This tag can't be used by users.
|
static |
Callback for optional custom takedown of player loop. Occurs before any effect on PlayerLoop. If Func returns true then it's assumed that the Func did it's own work and no other action is needed. If it returns false then the PlayerLoop is set to the default Unity player loop (which would overwrite any actions taken in the Func)..
|
static |
Get the Start and Requeue times for an ID.
| id | process ID |
|
static |
The initialization size for certain dicts.
|
static |
The initialization size for certain dicts.
|
staticget |
Best frame rate for current Run session.
|
staticget |
True if tiles are waiting to clone or refresh.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
How many active delayed callbacks.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
publicly-accesssible frame rate.
|
staticget |
Set true when frame rate is lower than the target.
|
staticget |
Get all tags.
|
staticget |
Get all tiles. Note: uses GuidToTile dictionary's Values.
|
staticget |
Get a list of all ToString from the delayed callbacks. Not for use in an update loop @ runtime aside from debugging. Used by SystemInfo window's Dump button.
|
staticget |
Number of GUIDs.
|
staticgetset |
Inhibits OnTpLibChangedEvents:
|
staticgetset |
Inhibits tilemap callbacks (OnTilemapPositionChanged, OntilemapTileChanged). Useful if you're doing a lot of Tilemap operations but don't want the system to handle these callbacks. Note that the internal DBs of TpLib will be incorrect; use SceneScan afterwards. That's not automatic!! The effect of this property isn't the same as InhibitOnTpLibChanged which just inhibits the callback. InhibitTilemapCallbacks causes the tilemap callbacks (OnTilemapPositionChanged, OntilemapTileChanged) to immediately return.
|
staticget |
In-Editor, returns true if EditorApplication.isPlayingOrWillChangePlaymode is true. In a built app this always returns true. One would expect the compiler to removed this method when it optimizes in an non-editor build.
true in play mode
always returns TRUE in a built application
|
staticget |
Property to determine if a scene scan is in progress.
true if scene scan active; otherwise, false.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticgetset |
Set the maximum number of tile clones that can occur on one TpLibUpdate. Note that if you set this to zero or LT 0 then the value used is uint.maxvalue which is a pretty big number. This value should be relatively small, but the exact value is app-dependent. If you never place TPT tiles in a running game then this can be ignored. A too-small value will increase the delay from when a TPT tile is painted to when it is cloned. That can affect the appearance of animated tiles.
|
staticgetset |
Set the maximum number of deferred callbacks that can occur on one TpLibUpdate. Note that if you set this to zero or LT 0 then the value used is long.maxvalue which is a pretty big number. This value should be relatively small, but the exact value is app-dependent.
|
staticget |
Get the current memory allocation settings for TpLib.
|
staticget |
A list of non tileplus tiles that were added or modified.
|
staticgetset |
Allows accessing the optional Guid maps. See GetTilePlusBaseFromGuid variants.
|
staticgetset |
Set this TRUE to stop all updating in TpLibUpdate. This stops all tweening, callbacks, tile cloning, etc.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
For statistics. Observable in SysInfo window.
|
staticget |
Get a string with abbreviated version information.
|
staticget |
Number of different tags.
|
staticgetset |
Target frame rate for current Run session.
|
staticget |
Is the target frame rate met?
|
staticget |
Number of interfaces.
|
staticget |
How many tilemaps are being tracked.
The tilemaps count.
|
staticget |
Number of different Types.
|
staticget |
|
staticget |
TpLibUpdate loop count, for diags.
|
staticget |
True if the internal update loop is running.
|
staticget |
Is the Tp update pump using the Player loop?
|
staticget |
Get a string with Name, Version, Build Timestamp.
|
staticget |
Worst frame rate for current Run session.
|
static |
If you want to subscribe to Tilemap.tilemapPositionsChanged use this event instead. The handler for this event in TpLib will also invoke these; its more efficient. Note that this is not always invoked, see if it is appropriate for your use. Note: don't use for monobehaviours or tiles.
|
static |
If you want to subscribe to Tilemap.tilemapTileChanged use this event instead. The handler for this event in TpLib will also invoke these; its more efficient. Note that this is not always invoked, see if it is appropriate for your use. Note: don't use for monobehaviours or tiles.
|
static |
Event when the TpLib changes due to an addition or deletion. NOTE that this event is NOT cleared when a scene loads or unloads, so if you have anything that could be deleted on a scene (un)load, be sure to use OnEnable and OnDisable to add and remove your callback target. ChangeType, bool is false for single tiles, true if this is part of a group of changes, Position, map.