Custom Command: "Set Tile"
💡
5
Sometimes you might want a command to modify a tile (for instance, to show a bridge over water, or to change an element of the decor, without having to make a GameObject for it). Add this script anywhere in your project to get a new “Set Tile” command
using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Tilemaps;
namespace Gyvr.Mythril2D
{
[Serializable]
public class SetTile : ICommand
{
[SerializeField] private Tile m_tile;
[SerializeField] private Tilemap m_tilemap;
[SerializeField] private Vector3Int m_position;
public Task Execute()
{
m_tilemap.SetTile(m_position, m_tile);
return Task.CompletedTask;
}
}
}

💬 Comments (6)
Want to continue the conversation?