/// <summary> /// Create new building GameObject and render it, /// attach BuildingModel, PlaceBuildingController and BuildingObjectController to the GameObject, /// pass the needed references to those components /// </summary> /// <param name="buildingModel">BuildingModel of the building</param> private void RenderBuilding(BuildingModel buildingModel, bool placeInstantly) { buildingModel.CbRegisterResourcesChanged(OnResourcesChanged); GameObject cube = Instantiate(g); // TODO: Placeholder //cube.SetActive(false); cube.transform.parent = this.transform; cube.name = buildingModel.buildingType.GetName(); cube.GetComponent <Renderer>().material.color = Color.red; cube.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); if (!placeInstantly) { cube.AddComponent <PlaceBuildingController>().SetReferences(buildingModel, mapLayer); } else { buildingModel.NotifyPlaced(); } cube.AddComponent <BuildingObjectController>().SetReferences(buildingModel, placeInstantly); buildingMenuPanel.SetActive(false); }