Пример #1
0
        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));
        }