Animated Tiles
Purpose
-
This demo illustrates how to control tiles from mouse clicks or from Unity UI buttons.
-
There are three scenes:
- MouseClicks:
- This scene uses a script called TpPickTile. Just click on the tiles themselves.
- TpPickTile uses either input system to directly message tiles.
- When you click the mouse it translates the pointer position into tilemap coordinates.
- Then it uses TpLib to locate the tile.
- If a tile is found it's ActivateAnimation method is used to toggle animation on/off.
- This scene uses a script called TpPickTile. Just click on the tiles themselves.
- MouseClicksDirect:
- This is a better approach for most practical uses (but not UnityUi) where you want to message a tile when using a tile as an active element in your scene.
- This scene uses a component called TpInputActionToTile.
- It REQUIRES the New Input System.
- It merely creates an instance of a TpActionToTile Scriptable Object.
- That S.O. does much the same work as TpPickTile, and sends ActionToTile packets to the tile if it supports being sent that type of message.
- Note that this S.O. supports Hover messages, which aren't used here.
- See the TileUi demo for more advanced uses of this S.O. variety.
- UnityUi:
- This scene uses a component called TpGuidToAction.
- The buttons each have their on-click events set to the 'Controller' GO with the TpGuidToAction.SendAction method as the target AND the GUID of the target tile as the parameter.
- The GUID is easily available with Painter or the Tile+Brush, just view the tile in the Selection Inspector and click the eyedropper icon to copy the GUID to the clipboard.
- It functions similarly to TpPickTile.
- MouseClicks: