public void ClearHighlight() { if (_gridCellHighlight != null) { _gridCellHighlightPool.Despawn(_gridCellHighlight); _gridCellHighlight = null; } }
private void HandleMouseOnTile(IntVector2 tileCoords) { if (_gridCellHighlight != null) { _gridCellHighlightPool.Despawn(_gridCellHighlight); } _gridCellHighlight = _gridCellHighlightPool.Spawn(tileCoords, new Color(1, 0, 0, 0.4f)); }
public void StopEditing() { _cancellationTokenSource?.Cancel(); _cancellationTokenSource = null; if (_gridCellHighlight != null) { _gridCellHighlightPool.Despawn(_gridCellHighlight); _gridCellHighlight = null; } _observers.ForEach(x => x.Dispose()); SetDefaultCursor(); }
private async void HandleTileClicked(IntVector2 tileCoords) { // Trigger highlight for mobile since mouse over does not happen there. HandleMouseOnTile(tileCoords); SetDefaultCursor(); // Allow cancellation when "StopEditing" is called. _cancellationTokenSource = new CancellationTokenSource(); // The task is ran "as uni task" to avoid opening a new thread. // We are showing a view controller which will require MonoBehaviours (needs main thread). await _delegate.Show(tileCoords, _cancellationTokenSource.Token).SuppressCancellationThrow(); _cancellationTokenSource = null; // Update highlight to match new mouse position _gridCellHighlightPool.Despawn(_gridCellHighlight); _gridCellHighlight = null; if (_gridInputManager.TileAtMousePosition != null) { HandleMouseOnTile(_gridInputManager.TileAtMousePosition.Value); } SetSectionTileCursor(); }
public void Despawn(IGridCellHighlight gridCellHighlight) { _monoPool.Despawn((GridCellHighlight)gridCellHighlight); _spawnedHighlights.Remove(gridCellHighlight); }
private void HandleMouseOnTile(IntVector2 tileCoords) { ClearHighlight(); _gridCellHighlight = _gridCellHighlightPool.Spawn(tileCoords, HIGHLIGHT_COLOR); }