public void DisplaySettingsFile(GameObject clickedButton) { // we need to clear out the children in the list before we generate new ones for (int i = 0; i < fieldsList.transform.childCount; i++) { fieldsList.transform.GetChild(i).gameObject.SetActive(false); Debug.Log("destroying: " + fieldsList.transform.GetChild(i).name); Destroy(fieldsList.transform.GetChild(i).gameObject); } string file = settingsFileFolderPath + "/" + clickedButton.GetComponentInChildren <Text> ().text; string tmpFile = clickedButton.GetComponentInChildren <Text> ().text.Substring(0, clickedButton.GetComponentInChildren <Text> ().text.Length - 5); Type fileType = System.Type.GetType(tmpFile); activeSettingsFileType = fileType; WidgetSettings displayedFile = XmlIO.Load(file, fileType) as WidgetSettings; object[] displayedValues = displayedFile.GetValues(); FieldInfo[] fieldsArray = fileType.GetFields(); for (int i = 0; i < fieldsArray.Length; i++) { GameObject fieldUI = Instantiate(Resources.Load("WidgetSettings/" + fieldsArray [i].FieldType.Name + "_UI")) as GameObject; fieldUI.transform.SetParent(fieldsList.transform); fieldUI.transform.FindChild("Title").GetComponent <Text>().text = fieldsArray[i].Name; fieldUI.GetComponent <FieldUIs>().SetFieldValue(displayedValues[i]); } }
public void SaveSettingsFile() { WidgetSettings objToSave = (WidgetSettings)System.Activator.CreateInstance(activeSettingsFileType); object[] valuesToSave = new object[fieldsList.childCount]; for (int i = 0; i < fieldsList.childCount; i++) { valuesToSave[i] = fieldsList.GetChild(i).GetComponent <FieldUIs>().GetFieldValue(); if (valuesToSave[i] == null) { //Debug.Log("need to decide how to implement the error message that should be displayed here"); errorWindow.gameObject.SetActive(true); errorWindow.GetChild(1).GetComponentInChildren <Text>().text = "Error: Inalid input, please correct settings."; return; } } objToSave.SetValues(valuesToSave); string file = settingsFileFolderPath + "/" + activeSettingsFileType.Name + ".sets"; Debug.Log(file); XmlIO.Save(objToSave, file); //LoadSettingsFiles(); }
static public void LoadMap(string path) { InputMap newMap = XmlIO.Load(path, typeof(InputMap)) as InputMap; newMap.Configure(); map.Append(newMap); }
public bool WriteXml(string file_path) { XmlDocument xmlDoc = new XmlDocument(); XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", null, null); xmlDoc.AppendChild(xmlDec); XmlElement ncamXml = xmlDoc.CreateElement("Lens"); XmlIO.Write(ncamXml, enabled, "Enabled"); XmlIO.Write(ncamXml, fileName, "FileName"); xmlDoc.AppendChild(ncamXml); try { xmlDoc.Save(file_path); } catch (System.Exception e) { Debug.LogError(e.Message); return(false); } return(true); }
public void ReadXml(XmlReader reader) { XmlSerializer serializer = new XmlSerializer(typeof(XmlIO)); reader.Read(); if (reader.IsEmptyElement) { return; } while (reader.NodeType != XmlNodeType.EndElement) { XmlIO xmlIO = serializer.Deserialize(reader) as XmlIO; if (xmlIO != null) { Children = xmlIO.Children; IsExpanded = xmlIO.IsExpanded; IsParentInclude = xmlIO.IsParentInclude; Title = xmlIO.Title; Explanation = xmlIO.Explanation.TrimStart(); ScriptDocument.Text = xmlIO.ScriptContent.TrimStart(); ExecFlagDict = xmlIO.ExecFlagDict; } } reader.Read(); }
private void OpenXml_Click(object sender, RoutedEventArgs e) { var dlg = new OpenFileDialog(); var res = dlg.ShowDialog(); if (res == null || !res.Value) { return; } try { var str = new FileStream(dlg.FileName, FileMode.Open); var buf = XmlIO.ReadFromXml(str); str.Close(); Context.Model = buf; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// There are only three settings files we need to load /// AvatarSettings, KeyBindings and WidgetControlSettings /// If those files are not found, save a copy of them with default settings. /// </summary> public void LoadSettingsFiles() { if (File.Exists(Application.dataPath + "/FullPackage/Settings/AvatarSettings.sets")) { a_Settings = XmlIO.Load(Application.dataPath + "/FullPackage/Settings/AvatarSettings.sets", typeof(AvatarSettings)) as AvatarSettings; ApplyAvatarSettings(); } else { SaveAvatarSettings(); } if (File.Exists(Application.dataPath + "/FullPackage/Settings/KeyBindings.sets")) { kb_Settings = XmlIO.Load(Application.dataPath + "/FullPackage/Settings/KeyBindings.sets", typeof(KeyBindings)) as KeyBindings; ApplyKeyBindings(); } else { SaveKeyBindings(); } if (File.Exists(Application.dataPath + "/FullPackage/Settings/WidgetControlSettings.sets")) { wc_Settings = XmlIO.Load(Application.dataPath + "/FullPackage/Settings/WidgetControlSettings.sets", typeof(WidgetControlSettings)) as WidgetControlSettings; ApplyWidgetControlSettings(); } else { SaveWidgetControlSettings(); } }
public bool ReadXml(string file_path) { XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(file_path); XmlNodeList docXml = xmlDoc.GetElementsByTagName("Lens"); XmlNode ncamXml = docXml[0]; if (ncamXml != null) { bool isEnabled = false; XmlIO.Read(ncamXml.ChildNodes[0], ref isEnabled); enabled = isEnabled; XmlIO.Read(ncamXml.ChildNodes[1], ref fileName); } } catch (System.Exception e) { Debug.LogError(e.Message); return(false); } return(true); }
public static void ReadTransform(XmlNode xmlNode, ref UnityEngine.Transform transform) { Vector3 vec = Vector3.zero; XmlNode localPosNode = xmlNode.ChildNodes[0]; XmlIO.Read(localPosNode.ChildNodes[0], ref vec.x); XmlIO.Read(localPosNode.ChildNodes[1], ref vec.y); XmlIO.Read(localPosNode.ChildNodes[2], ref vec.z); transform.localPosition = vec; XmlNode localEulerNode = xmlNode.ChildNodes[1]; XmlIO.Read(localEulerNode.ChildNodes[0], ref vec.x); XmlIO.Read(localEulerNode.ChildNodes[1], ref vec.y); XmlIO.Read(localEulerNode.ChildNodes[2], ref vec.z); transform.localEulerAngles = vec; XmlNode localScaleNode = xmlNode.ChildNodes[2]; XmlIO.Read(localScaleNode.ChildNodes[0], ref vec.x); XmlIO.Read(localScaleNode.ChildNodes[1], ref vec.y); XmlIO.Read(localScaleNode.ChildNodes[2], ref vec.z); transform.localScale = vec; }
private DeserializedLevels.Level getCurLevel(string xmlfilename) { deserializedLevels = XmlIO.LoadXml <DeserializedLevels>(xmlfilename); int startLevel = int.Parse(deserializedLevels.developer.startLevel); return(deserializedLevels.levels[startLevel - 1]);; }
/// <summary> /// プレイヤー情報をファイルに保存する。 /// </summary> /// <param name="value">保存する情報</param> /// <param name="filePath">保存先ファイルパス</param> /// <remarks>同期版</remarks> public static void Save(PlayerParameter value, string filePath) { // XML出力 XmlIO.WritePlayerParameter(value, AddExtension(filePath, XmlIO.Extension)); // JSON出力 //var jsonTask = JsonIO.WriteAsync(value, AddExtension(filePath, JsonIO.Extension)); }
//-------------这个类主要按照一定的规则解析从XML得到的字符串--------- /// <summary> /// 解析这个场景的npc /// </summary> public static string[] AnalySceneOfNpc(string sceneName) { string str = XmlIO.LoadNpcFromScene(sceneName); string[] npcArray = str.Split(','); return(npcArray); }
public void Load(string file) { scenarioContainer = XmlIO.LoadXml <ScenarioContainer>(file); AddStageInfoToDict(); AddCreateCharType2DToDict(); AddCreateChar2DToDict(); AddCreateChar3DToDict(); AddCreateObjType2DToDict(); AddCreateObj2DToDict(); AddCreateObj3DToDict(); AddStageSetToDict(); AddTextEventToDict(); AddPopUpEventToDict(); AddCardPopUpEventToDict(); AddSpeechBubbleOnEventToDict(); AddSphereImageOnEventToDict(); AddLoadSceneEventToDict(); AddQuarterEventToDict(); AddQuarterSelectEventToDict(); AddQuizEventToDict(); AddCaptureEventToDict(); AddPanelPopEventToDict(); AddTableSettingEventToDict(); AddSelectItemEventToDict(); AddBranchToDict(); AddInputFieldEventToDict(); AddVideoPlayEventToDict(); AddTouchGameEventToDict(); AddDeleteBlurEventToDict(); AddPaintEventToDict(); }
public void SaveSettingsFiles() { for (int i = 0; i < transform.childCount; i++) { ///////// THIS NEEDS TO BE CHANGED SINCE WIDGETSETTINGSBASE IS NOW A SCRIPTABLE OBJECT object componentToSave = transform.GetChild(i).GetComponent <WidgetSettingsBase>(); XmlIO.Save(componentToSave, transform.GetChild(i).name + "_settings.xml"); } }
public static void Save <TSettings>(TSettings settings, ExceptionHandler handler) where TSettings : IVisynAppSettings { if (settings == null) { return; } var path = AppSettingsPath; XmlIO.Serialize <TSettings>(settings, path, handler); }
/// <summary> /// 解析Npc的下一个状态 /// </summary> /// <param name="npcName"></param> /// <param name="step">当前状态</param> public static StoryStep AnalyNpcNextStep(string npcName, StoryStep step) { string str = XmlIO.LoadNpcChangeStep(npcName, step); str = str.Replace("Step", ""); int index = int.Parse(str); return((StoryStep)index); }
/// <summary> /// Read method through XmlReader /// </summary> /// <param name="filePath"></param> public void XmlRead(string filePath) { List <IFigure> figures = XmlIO.XmlRead(filePath); if (figures.Count > 20) { throw new NoPlaceException(); } this.figures = figures; }
/// <summary> /// プレイヤー情報をファイルに保存する。 /// </summary> /// <param name="value">保存する情報</param> /// <param name="filePath">保存先ファイルパス</param> /// <remarks>非同期版</remarks> public static async Task SaveAsync(PlayerParameter value, string filePath) { // XML出力 var xmlTask = XmlIO.WriteAsync(value, AddExtension(filePath, XmlIO.Extension)); // JSON出力 var jsonTask = JsonIO.WriteAsync(value, AddExtension(filePath, JsonIO.Extension)); await Task.WhenAll(xmlTask, jsonTask); }
private DeserializedLevels.Level getCurLevel() { deserializedLevels = XmlIO.LoadXml <DeserializedLevels>("Levels"); // if startlevel is in the XML i.e. <Developer StartLevel="3" /> then get level from there // otherwise start with level 1 int startLevel = int.Parse(deserializedLevels.developer.startLevel); return(deserializedLevels.levels[startLevel - 1]);; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Website_Name = Helpers.WEBSITE_NAME; Website_Url = Helpers.WEBSITE_URL; IO = new XmlIO(); }
private void SaveFile(string file) { try { XmlIO.SaveObjectToXML <List <ByteSignature> >(SignatureList, file); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public static WixProject Deserialize(string fileName, ExceptionHandler exceptionHandler) { var project = XmlIO.Deserialize <WixProject>(fileName, exceptionHandler); if (project == null) { return(null); } project.Analyze(fileName, exceptionHandler); return(project); }
/* * public float[] PGTranslationSpeeds * { * get { return DIRE.Instance.DisplayOrigin.GetComponent<PointAndGo>().TranslationSpeeds; } * set { DIRE.Instance.DisplayOrigin.GetComponent<PointAndGo>().TranslationSpeeds = value; } * } * * public bool MiniMapEnabled * { * get { return DIRE.Instance.Minimap.GetComponent<MiniMapManager>().isMiniActive; } * set { DIRE.Instance.Minimap.GetComponent<MiniMapManager>().SetMiniMapActive(value); } * } * * public Vector2 MinimapPosition * { * get { return DIRE.Instance.Minimap.GetComponent<RectTransform>().anchoredPosition; } * set { DIRE.Instance.Minimap.GetComponent<MiniMapManager>().SetMiniMapPosition(value); } * } * * public int MiniMapPixelSize * { * get { return DIRE.Instance.Minimap.GetComponent<MiniMapManager>().pixelDimension; } * set { DIRE.Instance.Minimap.GetComponent<MiniMapManager>().SetSize(value); } * } * * public float MiniMapCameraRadius * { * get { return DIRE.Instance.Minimap.GetComponent<MiniMapManager>().orthoCamRadiusFeet; } * set { DIRE.Instance.Minimap.GetComponent<MiniMapManager>().SetZoom(value); } * } * * public bool ShowMiniMapControls * { * get { return DIRE.Instance.Minimap.GetComponent<MiniMapManager>().isControlActive; } * set { DIRE.Instance.Minimap.GetComponent<MiniMapManager>().SetMiniMapControls(value); } * } */ /// <summary> /// Load preferences from a file. /// As preferences directly access data members in the DIRE scene and system, /// the mere act of loading the file will set the values in the system. /// </summary> /// <param name="path">Path to preferences file</param> /// <returns></returns> public static void Load(string path) { try { XmlIO.Load(path, typeof(Preferences)); } catch (Exception ex) { Debug.LogWarning("Error loading: " + path + Environment.NewLine + ex); } }
public static TSettings Load <TSettings>(ExceptionHandler handler) where TSettings : IVisynAppSettings { TSettings settings = XmlIO.Deserialize <TSettings>(AppSettingsPath, handler); if (settings == null) { settings = Activator.CreateInstance <TSettings>(); settings.InitializeDefaultSettings(null); } return(settings); }
private static void getLevelPrefabs(HashSet <string> xmlPrefabSet) { DeserializedLevels deserializedLevels = XmlIO.LoadXml <DeserializedLevels>("Levels"); foreach (DeserializedLevels.Level level in deserializedLevels.levels) { foreach (DeserializedLevels.Item item in level.items) { xmlPrefabSet.Add(item.prefab); } } }
//save the buttons in the scene into the XML file and the orginalHandler public void SaveButsToXML() { Debug.Log("generating saved button files based on current project"); originalHandler = new POIHandler(); foreach (Transform child in POIList.transform) { POI pointToAdd = child.GetComponent <POIInfoRef>().poiInfo.Point; originalHandler.AddPoint(pointToAdd); } XmlIO.Save(originalHandler, POI_GlobalVariables.XMLpath); }
//load the xml from specified path into the handler public void loadButsFromXML(string XMLpath, ref POIHandler handler) { if (File.Exists(XMLpath)) { //load the POIHandler.xml, the saved button files handler = XmlIO.Load(XMLpath, typeof(POIHandler)) as POIHandler; } else { Debug.Log("saved buttons not found! need to generate saved button files based on current project."); } }
/// <summary> /// 解析摄像机最大限制位置 /// </summary> /// <param name="sceneName"></param> public static void AnalyCameraPos(string sceneName) { string str = XmlIO.LoadCameraPosFormScene(sceneName); string[] strArray = str.Split(','); float xMin = float.Parse(strArray[0]); float xMax = float.Parse(strArray[1]); float yMin = float.Parse(strArray[2]); float yMax = float.Parse(strArray[3]); CameraFollow._instance.GetXYThresholdPos(xMin, xMax, yMin, yMax); }
private void OpenFile(string file) { try { SignatureList = XmlIO.LoadObjectFromXML <List <ByteSignature> >(file); DisplayList(); ClearSelection(); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
/// <summary> /// Saves character to file. /// </summary> public void SaveCharacters() { if (!initializing) { droppedCharacters = new List <DroppedCharacter>(); Debug.Log("saving " + charRoot.transform.childCount + " characters"); for (int i = 0; i < charRoot.transform.childCount; i++) { droppedCharacters.Add(new DroppedCharacter(charRoot.transform.GetChild(i).GetComponent <CharacterWander>())); } XmlIO.Save(droppedCharacters, characterFilePath); } }