public void DeSelect() { if (selected != null) { Destroy(selected.gameObject); } selected = null; buildable = null; }
/// <summary> /// Sets the building we want to spawn in /// </summary> /// <param name="newSelected"></param> public void SetSelected(GameObject newSelected) { DeSelect(); //creates new building GameObject go = Instantiate(newSelected, this.gameObject.transform); selected = go.transform; buildable = go.GetComponent <Buildable>(); }