public void Save(string fileName) { Container container = XmlTool.DeserializeObject <Container>(fileName); _parcelService.SetDepartment(container.Parcels); _containerRepository.Save(container); }
public static void LoadFromSave(string content, bool transparent = true, bool isNeedHandleCamera = true) { VRCattleManager.currentLoaded = content; VRCattleSaveXml saveXml = XmlTool.DeserializeObject <VRCattleSaveXml>(content); VRCattleDifferent.DisableObjsStatic(saveXml.isMale); int count = saveXml.disable.Count; for (int i = 0; i < count; i++) { string str = saveXml.disable[i]; Transform t = GetTransformByNodeID(str); if (t == null) { continue; } VRCattleManager.disabledObjs.Add(t); t.gameObject.SetActive(false); } VRCattleUIManager.instance.Page06SetBodyAndBt20_31State(saveXml.bodyStates); if (transparent) { count = saveXml.transparent.Count; for (int i = 0; i < count; i++) { Transform t = GetTransformByNodeID(saveXml.transparent[i]); if (t == null) { continue; } MeshRenderer mr = t.GetComponent <MeshRenderer>(); VRCattleManager.transparentObjs.Add(mr); Color color = mr.material.color; color.a = VRCattleManager.transparentValue; mr.material.color = color; } } if (isNeedHandleCamera) { VRCattleManager.instance.ResetBodyTransform(); Vector3 center = instance.GetCenter(); VRCattleCameraControll.instance.isScrollbar = false; VRCattleCameraControll.instance.Distance = 3.5f; VRCattleCameraControll.instance.SetTargetPoint(center); //VRCattleCameraControll.instance.ChangeDistance(); VRCattleCameraControll.instance.MoveToTargetPoint(); VRCattleObjectControll.instance.SetTargetPoint(center); } }
static void AddMaleFemaleToTupu() { string path = Application.dataPath + "/Resources/Tupu/"; string malePath = path + "Male/"; string femalePath = path + "Female/"; DirectoryInfo directory = new DirectoryInfo(path); FileInfo[] infos = directory.GetFiles(); VRCattle.VRCattleDifferent diff = FindObjectOfType <VRCattle.VRCattleDifferent>(); int length = infos.Length; for (int i = 0; i < length; i++) { if (infos[i].Extension == ".meta") { continue; } StreamReader sr = infos[i].OpenText(); string content = sr.ReadToEnd(); sr.Dispose(); sr.Close(); VRCattle.VRCattleSaveXml male = XmlTool.DeserializeObject <VRCattle.VRCattleSaveXml>(content); VRCattle.VRCattleSaveXml female = XmlTool.DeserializeObject <VRCattle.VRCattleSaveXml>(content); male.isMale = true; female.isMale = false; diff.AddToVSX(ref male, true); diff.AddToVSX(ref female, false); if (!Directory.Exists(malePath)) { Directory.CreateDirectory(malePath); } if (!Directory.Exists(femalePath)) { Directory.CreateDirectory(femalePath); } File.WriteAllText(malePath + infos[i].Name, XmlTool.SerializeObject <VRCattle.VRCattleSaveXml>(male)); File.WriteAllText(femalePath + infos[i].Name, XmlTool.SerializeObject <VRCattle.VRCattleSaveXml>(female)); } AssetDatabase.Refresh(); }