using UnityEngine;
namespace Flexalon
{
/// Specifies which cell a gameObject should occupy in a grid layout.
[AddComponentMenu("Flexalon/Flexalon Grid Cell"), HelpURL("https://www.flexalon.com/docs/gridLayout")]
public class FlexalonGridCell : FlexalonComponent
{
[SerializeField, Min(0)]
private int _column;
/// The column of the cell.
public int Column
{
get => _column;
set
{
_column = Mathf.Max(0, value);
MarkDirty();
}
}
[SerializeField, Min(0)]
private int _row;
/// The row of the cell.
public int Row
{
get => _row;
set
{
_row = Mathf.Max(0, value);
MarkDirty();
}
}
[SerializeField, Min(0)]
private int _layer;
/// The layer of the cell.
public int Layer
{
get => _layer;
set
{
_layer = Mathf.Max(0, value);
MarkDirty();
}
}
/// The cell to occupy.
public Vector3Int Cell
{
get => new Vector3Int(_column, _row, _layer);
set
{
_column = Mathf.Max(0, value.x);
_row = Mathf.Max(0, value.y);
_layer = Mathf.Max(0, value.z);
MarkDirty();
}
}
}
}