コード例 #1
0
    private void RemoveTerrain() // removes the clicked terrain and resets the tiles around it.
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Unit u;

        if (Physics.Raycast(ray, out rayHit))
        {
            u = rayHit.transform.gameObject.GetComponent <Unit>();
            if (u != null) // it might be tempting to put this and the nested if statment together with an &&, but that'll throw an error if h is null when it check h.Unit
            {
                ITerrain uIT = u.GetComponent <ITerrain>();
                uIT.ResetTiles();
                u.CurrentHex = null;
                uIT.DestroySelf();
            }
        }
    }