Methods
Simulate can be implemented to use the Editor update event to do something. In TpAnimatedTile and TpFlexAnimatedTile it’s used to show an animation preview. It's unlikely that you'd need to implement this yourself if you inherit from classes that already implement this feature.
TilePlusBase has two other methods that you probably want to override:
- StartUp
- GetTileData
- ResetState.
Overriding StartUp must be done a specific way: a simple example can be found in TpAnimatedTile. Basically, you must call the base method as usual, but pay attention to the return value: if it’s false your override must return false without doing anything else:
//this has to be the first thing to do.
if (!base.StartUp(position, tilemap, gameObject))
return false;
It would be an extremely bad idea to change any code in the Startup method in TilePlusBase. Worse than being eaten by the Sarlacc on Tatooine or looking into the atomic furnaces of the Forbidden Planet, Altair IV.
GetTileData is probably the most complicated override, aside from being sure to call the base class or duplicating its code, examine some of the examples for guidance. But it’s obviously extremely specific to what you’re trying to do. Be sure to use the tilemapIsPalette field to exit the method after the base call if tilemapIsPalette is true. Otherwise, your tile might animate in the Palette window. GetTileAnimationData code should also test tilemapIsPalette. See TpFlexAnimatedTile for examples.
ResetState is used in-editor when using the Bundle Tilemaps menu command or the TilePlus Bundler command in the hierarchy window’s context menu. It’s also used when you pick and re-paint a clone TPP tile or use TpLib.CopyAndPasteTile. The implementation must reset fields so that stale data isn’t persisted. Be sure to call the base method. This is a misleadingly simple method that you need to think about carefully. You don’t want to reset all fields, or you’ll be undoing changes made to your TPT tile. See the various implementations for examples.