private void ClearSelection() { if (selectedTile != null) { selectedTile.selected = false; selectedTile = null; } }
public void HandleTouchDown(Vector2 touch) { ClearSelection(); touchPosition = Camera.main.ScreenToWorldPoint(touch); touchPosition.z = 0; //check panel grid var tile = panelGrid.TileCloseToPoint(touchPosition); if (tile == null || !tile.gameObject.activeSelf) { //check word grid tile = wordGrid.TileCloseToPoint(touchPosition); if (tile != null && tile.gameObject.activeSelf && tile.IsMovable()) { //pick tile from panel var tempTile = Instantiate(panelGrid.gridTileGO) as GameObject; tempTileOrigin = tile; selectedTile = tempTile.GetComponent <CrossingTile> (); selectedTile.transform.localScale = panelGrid.transform.localScale; selectedTile.transform.parent = wordGrid.transform; selectedTile.transform.localPosition = tile.transform.localPosition; selectedTile.gridType = CrossingTile.GRID_TYPE.WORD_GRID; selectedTile.SetTileData(tile.TypeChar); selectedTile.ShowTemporary(); tile.ShowGap(); } } else { selectedTile = tile; } if (selectedTile != null) { selectedTile.Select(true); } }