using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
namespace MoreMountains.Tools
{
///
/// A super simple component you can add to a tilemap to get a button to clean it from all tiles
///
public class MMTilemapCleaner : MonoBehaviour
{
/// Debug buttons
[MMInspectorButton("Clean")]
public bool CleanButton;
[MMInspectorButton("CleanAllChildren")]
public bool CleanAllButton;
protected Tilemap _tilemap;
protected Tilemap[] _tilemaps;
///
/// Cleans all tiles on the corresponding tilemap
///
public virtual void Clean()
{
_tilemap = this.gameObject.GetComponent();
if (_tilemap != null)
{
_tilemap.ClearAllTiles();
}
}
///
/// Cleans all tiles on all tilemaps that are set as children of this object
///
public virtual void CleanAllChildren()
{
_tilemaps = GetComponentsInChildren();
foreach (Tilemap tilemap in _tilemaps)
{
tilemap.ClearAllTiles();
}
}
}
}