public void RegisterBuilding(BuildingBase building) { buildings.Add(building); //building.government = this; building.team = this.team; building.transform.parent = this.transform; building.tag = this.tag; foreach (var renderer in building.GetComponentsInChildren <MeshRenderer>()) { renderer.sharedMaterial = buildingMaterial; } }
public void Setup(BuildingBase prefab, int dataID) { if (building != null) { Destroy(building.gameObject); } this.dataID = dataID; building = Instantiate(prefab, transform.position, prefab.transform.rotation, transform); building.name = "Ghost " + building.name; building.CacheEffects(); building.enabled = false; building.ToggleBuildingEffects(false); materials = new List <Material>(); startingColors = new List <Color>(); foreach (Renderer rend in building.GetComponentsInChildren <Renderer>()) { foreach (Material m in rend.materials) { if (!m.HasProperty("_Color")) { continue; } materials.Add(m); Color c = m.color; c.a = AlphaValue; m.color = c; startingColors.Add(m.color); } } MakeBuildingMeshTransparent(); AdjustBuildingMeshToUnavailableColor(building.IsBuildable(dataID)); }