void OnMouseUp() { Cell.clickTimer.Stop(); // If slow click, ignore. if (Cell.clickTimer.ElapsedMilliseconds > 300) { return; } if (Input.GetMouseButtonUp(0)) { Cell cellObject = this.gameObject.GetComponent(typeof(Cell)) as Cell; Selection selection = Cell.GetSelection(); if (!this.IsSelected()) { // Only add the cell to the existing selection if it is contiguous with the existing selection. // Otherwise, create a new selection. if (selection.BoundaryCells.Contains(cellObject)) { selection.AddCell(cellObject); } else { selection.Clear(); selection.AddCell(cellObject); } this.originalColor = this.rend.material.color; this.rend.material.color = Cell.highlightColor; } else { selection.RemoveCell(cellObject); this.rend.material.color = this.originalColor; } UnityEngine.Debug.Log(selection.SelectedCells.Count + " selected cells."); } }