public void clickAddSkin()
        {
            GameObject createSkinComp = buildingMenu.transform.Find("Panel").Find("CreateSkinComponentBuilding").gameObject;
            GameObject skinList = buildingMenu.transform.Find("Panel").Find("ScrollRect").Find("Content Panel").gameObject;
            GameObject skinItem = (GameObject)MonoBehaviour.Instantiate(Resources.Load("Prefabs/Menu/BuildingSkin"));

            Toggle skinitemToggle = skinItem.transform.Find("Panel").Find("Toggle").gameObject.GetComponent<Toggle>();
            skinitemToggle.isOn = true;

            Text skinitemName = skinItem.transform.Find("Panel").Find("Text_Type").gameObject.GetComponent<Text>();
            InputField ifnewItemName = createSkinComp.transform.Find("Panel").Find("InputField_SkinName").GetComponent<InputField>();
            skinitemName.text = ifnewItemName.text;

            Text skinitemSize = skinItem.transform.Find("Panel").Find("Text_Size").GetComponent<Text>();
            InputField ifnewItemSize = createSkinComp.transform.Find("Panel").Find("InputField_TextureWidth").GetComponent<InputField>();
            skinitemSize.text = ifnewItemSize.text;

            RawImage skinitemColor = skinItem.transform.Find("Panel").Find("Image_ColorTexture").GetComponent<RawImage>();
            skinitemColor.texture = colorTexture;
            RawImage skinitemNormal = skinItem.transform.Find("Panel").Find("Image_NormalTexture").GetComponent<RawImage>();
            skinitemNormal.texture = normalTexture;
            RawImage skinitemSpecular = skinItem.transform.Find("Panel").Find("Image_SpecularTexture").GetComponent<RawImage>();
            skinitemSpecular.texture = specularTexture;

            skinItem.transform.SetParent(skinList.transform);

            BuildingMaterial mat = new BuildingMaterial();
            mat.isActive = true;
            mat.name = skinitemName.text;
            mat.width = float.Parse(skinitemSize.text);
            mat.colorTexturePath = colorTexturePath;
            mat.normalTexturePath = normalTexturePath;
            mat.specularTexturePath = specularTexturePath;
            materialList.Add(mat);

            //Clear Menu

            ifnewItemSize.text = "";
            ifnewItemName.text = "";

            GameObject specularTextureImageView = createSkinComp.transform.Find("Panel").gameObject.transform.Find("SpecularTexture").gameObject;
            specularTextureImageView.GetComponent<RawImage>().texture = null;
            GameObject specularTextureText = createSkinComp.transform.Find("Panel").gameObject.transform.Find("Text_Specular").gameObject;
            specularTextureText.GetComponent<Text>().text = "Click to Add Specular Texture";

            GameObject colorTextureImageView = createSkinComp.transform.Find("Panel").gameObject.transform.Find("ColorTexture").gameObject;
            colorTextureImageView.GetComponent<RawImage>().texture = null;
            GameObject colorTextureText = createSkinComp.transform.Find("Panel").gameObject.transform.Find("Text_Color").gameObject;
            colorTextureText.GetComponent<Text>().text = "Click to Add Color Texture";

            GameObject normalTextureImageView = createSkinComp.transform.Find("Panel").gameObject.transform.Find("NormalTexture").gameObject;
            normalTextureImageView.GetComponent<RawImage>().texture = null;
            GameObject normalTextureText = createSkinComp.transform.Find("Panel").gameObject.transform.Find("Text_Normal").gameObject;
            normalTextureText.GetComponent<Text>().text = "Click to Add Normal Texture";
        }
Пример #2
0
        public InitialConfigurations fillConfig()
        {
            InitialConfigurations config = new InitialConfigurations();

            //HIGHWAY CONFIGURATIONS
            config.highwayConfig = new List <HighwayConfigurations>();
            string[] highwayTypes = new string[] { "HighwayResidential", "HighwayPrimary", "HighwaySecondary", "HighwayTertiary", "HighwayTertiaryLink",
                                                   "HighwayUnclassified", "HighwayService", "HighwayPath", "HighwayFootway",
                                                   "HighwayPavement", "Railway", "River" };
            float[] highwaySizes = new float[] { 6.0f, 10.0f, 10.0f, 8.0f, 8.0f, 7.0f, 4.0f, 6.0f, 4.0f, 2.0f, 1.5f, 8.0f };

            string[] highwayMaterials = new string[] { "Materials/Highway/Mat_Residential", "Materials/Highway/Mat_Primary",
                                                       "Materials/Highway/Mat_Secondary", "Materials/Highway/Mat_Tertiary", "Materials/Highway/Mat_TertiaryLink", "Materials/Highway/Mat_Unclassified",
                                                       "Materials/Highway/Mat_Service", "Materials/Highway/Mat_Path", "Materials/Highway/Mat_Footway",
                                                       "Materials/Highway/Mat_Pavement", "Materials/Highway/Mat_Railway", "Materials/Highway/Mat_River" };

            for (int k = 0; k < highwayTypes.Length; k++)
            {
                HighwayConfigurations hc = new HighwayConfigurations();
                hc.size         = highwaySizes[k];
                hc.type         = highwayTypes[k];
                hc.materialPath = highwayMaterials[k];
                config.highwayConfig.Add(hc);
            }

            //RIVER CONFIGURATIONS [NOT USED]
            config.riverConfig = new RiverConfigurations();
            config.riverConfig.materialPath = "Materials/River/??";
            config.riverConfig.size         = 6.0f;

            //AREA CONFIGURATIONS [NOT USED]
            config.areaConfig = new AreaConfigurations();
            config.areaConfig.defaultColor = new Vector3(0.3f, 0.3f, 0.3f);

            //BARRIER CONFIGURATIONS
            config.barrierConfig = new List <BarrierConfigurations>();

            float[]  barrierHeight  = new float[] { 2.0f, 1.5f, 15.0f, 3.0f, 2.0f };
            float[]  barrierWidth   = new float[] { 0.1f, 0.3f, 3.0f, 0.3f, 0.5f };
            string[] barrierTypes   = new string[] { "Fence", "Wall", "City Wall", "Retaining Wall", "Default" };
            string[] barrierPrefabs = new string[] { "Materials/Barrier/chainlink", "Materials/Barrier/BrickWall",
                                                     "Materials/Barrier/CityWall", "Materials/Barrier/RetainingWall",
                                                     "Materials/Barrier/Default" };
            for (int k = 0; k < barrierTypes.Length; k++)
            {
                BarrierConfigurations bar = new BarrierConfigurations();
                bar.width  = barrierWidth[k];
                bar.height = barrierHeight[k];
                bar.Path   = barrierPrefabs[k];
                bar.name   = barrierTypes[k];
                config.barrierConfig.Add(bar);
            }

            //BUILDING CONFIGURATIONS
            config.buildingConfig = new BuildingConfigurations();
            config.buildingConfig.defaultColor = new Vector3(0.5f, 0.5f, 0.5f);
            config.buildingConfig.minheight    = 14.0f;
            config.buildingConfig.maxheight    = 18.0f;
            config.buildingConfig.defaultSkins = new List <BuildingMaterial>();

            List <string> skinNames = new List <string>();

            skinNames.Add("White Concrete");
            skinNames.Add("Dark Brick");
            skinNames.Add("Light Brick");
            skinNames.Add("White Concrete 2");
            skinNames.Add("Dark Brick 2");
            skinNames.Add("Antic Stones");
            skinNames.Add("Kiosk");
            //---------------------
            skinNames.Add("White Historic");
            skinNames.Add("Yellow-Orrange Concrete");
            skinNames.Add("Wide Historic");
            skinNames.Add("Old Concrete 2-floor");
            skinNames.Add("Old Stone");
            skinNames.Add("White Stone");
            skinNames.Add("White Concrete 3");
            skinNames.Add("Brick");
            skinNames.Add("Old Concrete with Shop");
            skinNames.Add("Brick 2");
            skinNames.Add("Old Concrete");
            skinNames.Add("Yellow Historic");
            skinNames.Add("Yellow Concrete with Shop");
            skinNames.Add("Brown-White Concrete");
            skinNames.Add("Orange Wide");
            skinNames.Add("White Stone 2");
            skinNames.Add("White Stone Modern");
            skinNames.Add("White Concrete Modern");
            skinNames.Add("Office Type");
            skinNames.Add("White Concrete 4");

            float[] skinSizes = new float[] { 16.0f, 16.0f, 12.0f, 8.0f, 8.0f, 30.0f, 2.0f, 12.0f, 20.0f, 24.0f, 8.0f, 16.0f, 8.0f, 8.0f, 8.0f, 12.0f, 16.0f, 16.0f, 16.0f, 12.0f, 16.0f, 24.0f, 12.0f, 16.0f, 20.0f, 16.0f, 16.0f };

            //float[] skinSizes = new float[] {16.0f,16.0f,12.0f,8.0f,8.0f,30.0f,2.0f};
            List <string> colorTexturePath = new List <string>();

            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture1.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture2.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture3.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture4.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture5.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/towerTexture.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/KioskTexture.jpg");

            List <string> normalTexturePath = new List <string>();

            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building5Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapTower.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapKiosk.png");

            List <string> specularTexturePath = new List <string>();

            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Specular.png");
            specularTexturePath.Add("");
            specularTexturePath.Add("");
            specularTexturePath.Add("");


            for (int i = 1; i <= 20; i++)
            {
                colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/ColorTex/BuildingTexture" + i + "_COLOR.png");
                normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/NormalTex/BuildingTexture" + i + "_NRM.png");
                specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/SpecularTex/BuildingTexture" + i + "_SPEC.png");
            }

            for (int k = 0; k < skinNames.Count; k++)
            {
                BuildingMaterial mat = new BuildingMaterial();
                mat.name                = skinNames[k];
                mat.width               = skinSizes[k];
                mat.colorTexturePath    = colorTexturePath[k];
                mat.normalTexturePath   = normalTexturePath[k];
                mat.specularTexturePath = specularTexturePath[k];
                mat.isActive            = true;

                config.buildingConfig.defaultSkins.Add(mat);
            }

            config.buildingConfig.defaultSkins[5].isActive = false;
            config.buildingConfig.defaultSkins[6].isActive = false;

            return(config);
        }
        public InitialConfigurations fillConfig()
        {
            InitialConfigurations config = new InitialConfigurations();

            //HIGHWAY CONFIGURATIONS
            config.highwayConfig = new List<HighwayConfigurations>();
            string[] highwayTypes = new string[] {"HighwayResidential", "HighwayPrimary", "HighwaySecondary", "HighwayTertiary","HighwayTertiaryLink",
                                                  "HighwayUnclassified", "HighwayService", "HighwayPath", "HighwayFootway",
                                                  "HighwayPavement", "Railway", "River"};
            float[] highwaySizes = new float[] {6.0f, 10.0f, 10.0f, 8.0f, 8.0f, 7.0f, 4.0f, 6.0f, 4.0f, 2.0f, 1.5f, 8.0f };

            string[] highwayMaterials = new string[] {"Materials/Highway/Mat_Residential", "Materials/Highway/Mat_Primary",
            "Materials/Highway/Mat_Secondary","Materials/Highway/Mat_Tertiary", "Materials/Highway/Mat_TertiaryLink", "Materials/Highway/Mat_Unclassified",
            "Materials/Highway/Mat_Service", "Materials/Highway/Mat_Path", "Materials/Highway/Mat_Footway",
            "Materials/Highway/Mat_Pavement", "Materials/Highway/Mat_Railway","Materials/Highway/Mat_River" };

            for(int k=0 ; k < highwayTypes.Length ; k++)
            {
                HighwayConfigurations hc = new HighwayConfigurations();
                hc.size = highwaySizes[k];
                hc.type = highwayTypes[k];
                hc.materialPath = highwayMaterials[k];
                config.highwayConfig.Add(hc);
            }

            //RIVER CONFIGURATIONS [NOT USED]
            config.riverConfig = new RiverConfigurations();
            config.riverConfig.materialPath = "Materials/River/??";
            config.riverConfig.size = 6.0f;

            //AREA CONFIGURATIONS [NOT USED]
            config.areaConfig = new AreaConfigurations();
            config.areaConfig.defaultColor = new Vector3(0.3f, 0.3f, 0.3f);

            //BARRIER CONFIGURATIONS
            config.barrierConfig = new List<BarrierConfigurations>();

            float[] barrierHeight = new float[] {2.0f,1.5f,15.0f,3.0f, 2.0f };
            float[] barrierWidth = new float[] { 0.1f,0.3f,3.0f,0.3f, 0.5f };
            string[] barrierTypes = new string[]{"Fence", "Wall", "City Wall", "Retaining Wall", "Default"};
            string[] barrierPrefabs = new string[]{"Materials/Barrier/chainlink", "Materials/Barrier/BrickWall",
                                                   "Materials/Barrier/CityWall", "Materials/Barrier/RetainingWall",
                                                   "Materials/Barrier/Default"};
            for (int k = 0; k < barrierTypes.Length; k++)
            {
                BarrierConfigurations bar = new BarrierConfigurations();
                bar.width = barrierWidth[k];
                bar.height = barrierHeight[k];
                bar.Path = barrierPrefabs[k];
                bar.name = barrierTypes[k];
                config.barrierConfig.Add(bar);
            }

            //BUILDING CONFIGURATIONS
            config.buildingConfig = new BuildingConfigurations();
            config.buildingConfig.defaultColor = new Vector3(0.5f, 0.5f, 0.5f);
            config.buildingConfig.minheight = 14.0f;
            config.buildingConfig.maxheight = 18.0f;
            config.buildingConfig.defaultSkins = new List<BuildingMaterial>();

            List<string> skinNames = new List<string>();
            skinNames.Add("White Concrete");
            skinNames.Add("Dark Brick");
            skinNames.Add("Light Brick");
            skinNames.Add("White Concrete 2");
            skinNames.Add("Dark Brick 2");
            skinNames.Add("Antic Stones");
            skinNames.Add("Kiosk");
            //---------------------
            skinNames.Add("White Historic");
            skinNames.Add("Yellow-Orrange Concrete");
            skinNames.Add("Wide Historic");
            skinNames.Add("Old Concrete 2-floor");
            skinNames.Add("Old Stone");
            skinNames.Add("White Stone");
            skinNames.Add("White Concrete 3");
            skinNames.Add("Brick");
            skinNames.Add("Old Concrete with Shop");
            skinNames.Add("Brick 2");
            skinNames.Add("Old Concrete");
            skinNames.Add("Yellow Historic");
            skinNames.Add("Yellow Concrete with Shop");
            skinNames.Add("Brown-White Concrete");
            skinNames.Add("Orange Wide");
            skinNames.Add("White Stone 2");
            skinNames.Add("White Stone Modern");
            skinNames.Add("White Concrete Modern");
            skinNames.Add("Office Type");
            skinNames.Add("White Concrete 4");

            float[] skinSizes = new float[] { 16.0f, 16.0f, 12.0f, 8.0f, 8.0f,30.0f,2.0f, 12.0f, 20.0f, 24.0f, 8.0f, 16.0f, 8.0f, 8.0f, 8.0f, 12.0f, 16.0f, 16.0f, 16.0f, 12.0f, 16.0f, 24.0f, 12.0f, 16.0f, 20.0f, 16.0f, 16.0f };

            //float[] skinSizes = new float[] {16.0f,16.0f,12.0f,8.0f,8.0f,30.0f,2.0f};
            List<string> colorTexturePath = new List<string>();
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture1.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture2.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture3.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture4.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture5.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/towerTexture.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/KioskTexture.jpg");

            List<string> normalTexturePath = new List<string>();
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building5Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapTower.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapKiosk.png");

            List<string> specularTexturePath = new List<string>();
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Specular.png");
            specularTexturePath.Add("");
            specularTexturePath.Add("");
            specularTexturePath.Add("");

            for (int i = 1; i <= 20; i++)
            {
                colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/ColorTex/BuildingTexture" + i + "_COLOR.png");
                normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/NormalTex/BuildingTexture" + i + "_NRM.png");
                specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/SpecularTex/BuildingTexture" + i + "_SPEC.png");
            }

            for (int k = 0; k < skinNames.Count; k++)
            {
                BuildingMaterial mat = new BuildingMaterial();
                mat.name = skinNames[k];
                mat.width = skinSizes[k];
                mat.colorTexturePath = colorTexturePath[k];
                mat.normalTexturePath = normalTexturePath[k];
                mat.specularTexturePath = specularTexturePath[k];
                mat.isActive = true;

                config.buildingConfig.defaultSkins.Add(mat);
            }

            config.buildingConfig.defaultSkins[5].isActive = false;
            config.buildingConfig.defaultSkins[6].isActive = false;

            return config;
        }