// Select placed building private void SelectBuilding(Touch touch) { Ray ray = cam.ScreenPointToRay(touch.position); RaycastHit hit; if (touch.phase == TouchPhase.Began) { //Debug.Log("Select :" + buildingController); if (Physics.Raycast(ray, out hit, Mathf.Infinity, buildingMinionLayer)) { if (previewController != null) { previewController.SetSelected(false); previewController.ChangeColor(); } GameObject hitGO = hit.collider.gameObject; //Debug.Log(hitGO.name); hitGO.GetComponent <PreviewController>().SetSelected(true); previewController = hitGO.GetComponent <PreviewController>(); previewController.ChangeColor(); panelController.CloseBuildPanel(); panelController.OpenEditPanel(previewController); isOpenEditPanel = true; } else if (Physics.Raycast(ray, out hit, Mathf.Infinity, environmentLayer)) { if (previewController != null) { previewController.SetSelected(false); previewController.ChangeColor(); } } else { if (previewController != null) { previewController.SetSelected(false); } } } }