public void ClickSave() { InitialConfigLoader loader = new InitialConfigLoader(); InitialConfigurations config = loader.loadInitialConfig(); List<BarrierConfigurations> newBarrierConfig = new List<BarrierConfigurations>(); for(int i = 0 ; i < config.barrierConfig.Count ; i++) { string GOname = "BarrierSkin " + i; var skinitem = barrierMenu.transform.Find("Panel").Find("Scroll Rect").Find("Content Panel").Find(GOname).Find("Panel"); BarrierConfigurations barrieritem = new BarrierConfigurations(); barrieritem.name = skinitem.Find("TextName").GetComponent<Text>().text; barrieritem.width = float.Parse(skinitem.Find("InputField_Thickness").GetComponent<InputField>().text); barrieritem.height = float.Parse(skinitem.Find("InputField_Height").GetComponent<InputField>().text); barrieritem.Path = materialPaths[i]; if(isTextureChanged[i]) { Material mat = (Material)Resources.Load(barrieritem.Path); byte[] fileData = File.ReadAllBytes(texturePaths[i]); Texture2D tex = new Texture2D(2, 2); tex.LoadImage(fileData); mat.mainTexture = tex; mat.mainTextureScale = new Vector2(5, 1); } } config.barrierConfig = newBarrierConfig; loader.saveInitialConfig(Path.Combine(Application.persistentDataPath, "ConfigFiles/initialConfig.xml"), config); barrierMenu.SetActive(false); }
public void ClickReset() { InitialConfigLoader loader = new InitialConfigLoader(); InitialConfigurations config = loader.loadInitialConfig(); InitialConfigurations tmpConfig = loader.fillConfig(); config.barrierConfig = tmpConfig.barrierConfig; configLoadHelper(config); }
public void ClickSave() { InitialConfigLoader loader = new InitialConfigLoader(); InitialConfigurations config = loader.loadInitialConfig(); List<HighwayConfigurations> newHighwayConfig = new List<HighwayConfigurations>(); for (int i = 0; i < config.highwayConfig.Count; i++) { string GOname = "HighwaySkin " + i; var skinitem = highwayMenu.transform.Find("Panel").Find("Scroll Rect").Find("Content Panel").Find(GOname).Find("Panel"); HighwayConfigurations highwayitem = new HighwayConfigurations(); highwayitem.type = skinitem.Find("Text_Type").GetComponent<Text>().text; highwayitem.size = float.Parse(skinitem.Find("InputField_Width").GetComponent<InputField>().text); highwayitem.leftSidewalk = skinitem.Find("ToggleLeftSideWalk").GetComponent<Toggle>().isOn; highwayitem.rightSidewalk = skinitem.Find("ToggleRightSideWalk").GetComponent<Toggle>().isOn; highwayitem.leftSidewalkSize = float.Parse(skinitem.Find("InputField LeftSize").GetComponent<InputField>().text); highwayitem.rightSidewalkSize = float.Parse(skinitem.Find("InputField RightSize").GetComponent<InputField>().text); highwayitem.materialPath = materialPaths[i]; if (isTextureChanged[i]) { Material mat = (Material)Resources.Load(highwayitem.materialPath); byte[] fileData = File.ReadAllBytes(texturePaths[i]); Texture2D tex = new Texture2D(2, 2); tex.LoadImage(fileData); mat.mainTexture = tex; mat.mainTextureScale = new Vector2(5, 1); } newHighwayConfig.Add(highwayitem); } config.highwayConfig = newHighwayConfig; loader.saveInitialConfig(Path.Combine(Application.persistentDataPath, "ConfigFiles/initialConfig.xml"), config); highwayMenu.SetActive(false); }
private void loadConfig() { InitialConfigLoader loader = new InitialConfigLoader(); InitialConfigurations config = loader.loadInitialConfig(); configLoadHelper(config); }
public void clickSave() { InitialConfigLoader loader = new InitialConfigLoader(); InitialConfigurations config = loader.loadInitialConfig(); //Create new Building Config Part BuildingConfigurations newbuildingconfig = new BuildingConfigurations(); InputField min = buildingMenu.transform.Find("Panel").Find("HeightComponent").Find("InputField_Min").GetComponent<InputField>(); newbuildingconfig.minheight = float.Parse(min.text); InputField max = buildingMenu.transform.Find("Panel").Find("HeightComponent").Find("InputField_Max").GetComponent<InputField>(); newbuildingconfig.maxheight = float.Parse(max.text); newbuildingconfig.defaultSkins = materialList; Transform contentPanel = buildingMenu.transform.Find("Panel").Find("ScrollRect").Find("Content Panel"); int index = 0; foreach (Transform child in contentPanel) { Toggle t= child.Find("Panel").Find("Toggle").GetComponent<Toggle>(); newbuildingconfig.defaultSkins[index].isActive = t.isOn; index++; } config.buildingConfig = newbuildingconfig; loader.saveInitialConfig(Path.Combine(Application.persistentDataPath, "ConfigFiles/initialConfig.xml"), config); buildingMenu.SetActive(false); }
public void clickReset() { InitialConfigLoader loader = new InitialConfigLoader(); InitialConfigurations config = loader.loadInitialConfig(); InitialConfigurations tmpconfig = loader.fillConfig(); config.buildingConfig = tmpconfig.buildingConfig; configLoadHelper(config); }