I have created the following custom tile and slightly altered the "GetTileData" function, to become my "ChangeTile" function. It requires the same information to be passed over, but also requires a Sprite:
using UnityEngine;
using UnityEngine.Tilemaps;
[CreateAssetMenu(fileName = "New AStarTile", menuName = "Tiles/AStarTile")]
public class AStarTile : Tile
{
public TileScriptableObject tileScriptableObject;
public Sprite litSide;//Tile image that should be shown when lit
public Sprite darkSide;//Tile image that should be shown when dark
public bool currentlyLit = false;//Whether the tile has been flipped
public void ChangeTile(Vector3Int position, ITilemap tilemap, ref TileData tileData, Sprite newSprite)
{
tileData.sprite = newSprite;
tilemap.RefreshTile(position);
}
}
I am using the following line to call the function:
selectedTile.ChangeTile(clickPos, tileMap, , selectedTile.litSide);
I dont understand how I find "ref TileData tileData" needed for the function. Like what is the exact thing I put in the 3rd slot of the line above?
I can provide the full script if you need more information. Thanks.
↧