After a successful attempt at the Integration Challenge, I went a little step further and added some functionality for removing towers on right mouse button as well as freeing up the block that they were on.
Simple, but effective. Why did I want to do this? To see if I could
private void OnMouseOver()
{
if (Input.GetMouseButtonDown(0))
{
if (isPlaceable)
{
towerSpawn = Instantiate(towerPrefab, transform.position, Quaternion.identity);
towerSpawn.transform.parent = towerParent;
isPlaceable = false;
}
else
{
print("Can't place at " + gameObject.name);
}
}
else if (Input.GetMouseButtonDown(1))
{
if (towerSpawn)
{
Destroy(towerSpawn.gameObject);
isPlaceable = true;
}
}
}