Example #1
0
    private void EraseInput(Vector3 input)
    {
        if (Event.current.type == EventType.Layout)
        {
            HandleUtility.AddDefaultControl(0);
        }

        //Erase cell
        if ((Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag) && Event.current.button == 0)
        {
            Vector3Int index = _grid.GetIndexByPosition(ref input);
            MapTileGridCreator.Core.Cell cell = _grid.TryGetCellByIndex(ref index);

            if (cell != null)
            {
                _grid.DeleteCell(cell);
                Selection.SetActiveObjectWithContext(_grid.gameObject, null);
                Undo.DestroyObjectImmediate(cell.gameObject);
            }
        }
    }