public void createContent() { saveDataList = GameObject.Find("SaveDataCanvas"); if (saveDataList.GetComponent <Canvas>().enabled == true) { saveDataList.GetComponent <Canvas>().enabled = false; return; } saveDataContainer = SaveDataContainer.Load(Application.persistentDataPath + "/SaveDataContainer.xml"); feelings = saveDataContainer.SaveDataArray; RectTransform rt = content.GetComponent(typeof(RectTransform)) as RectTransform; RectTransform rtf = FeelingButtonPrefab.GetComponent(typeof(RectTransform)) as RectTransform; rt.sizeDelta = new Vector2(rt.sizeDelta.x, feelings.GetLength(0) * (rtf.GetComponent <LayoutElement>().minHeight + 2 * rt.GetComponent <VerticalLayoutGroup>().spacing)); for (int i = 0; i < feelings.GetLength(0); i++) { GameObject tempObject; tempObject = Instantiate(FeelingButtonPrefab, FeelingButtonPrefab.transform.position, FeelingButtonPrefab.transform.rotation) as GameObject; tempObject.transform.SetParent(content.transform, false); Text textObject = tempObject.GetComponentInChildren(typeof(Text)) as Text; textObject.text = feelings[i].feeling.feeling + feelings[i].date; } saveDataList.GetComponent <Canvas>().enabled = true; }
// Use this for initialization void Start() { T3FS = GameObject.FindObjectOfType <Top3FeelingsScript>(); GICS = GameObject.FindObjectOfType <GraphInfoControllerScript>(); table = new Dictionary <int, float>(); feelingCountsTable = new Dictionary <string, int>(); graph = newGraph.GetComponent <WMG_Axis_Graph>(); try { if (useRandomData) { saveDataContainer = SaveDataContainer.LoadFromText(randomData.text); } else { saveDataContainer = SaveDataContainer.Load(Application.persistentDataPath + "/SaveDataContainer.xml"); } feelings = saveDataContainer.SaveDataArray; } catch (Exception e) { Debug.Log("SaveData load failed"); } currentWeek = GetWeekValue(feelings[feelings.GetLength(0) - 1].date); currentMonth = GetMonthValue(feelings[feelings.GetLength(0) - 1].date); currentYear = feelings[feelings.GetLength(0) - 1].date.Year; //if (feelings.GetLength(0) == 0) return; //date = feelings[0].date; //currentDateValue = 0; //for (int i = 0; i < feelings.GetLength(0); i++) //{ // if (i == feelings.GetLength(0) - 1) // { // currentDateValue += (int)feelings[i].feeling.type; // table.Add(GetDateValue(feelings[i].date), currentDateValue); // break; // } // if (GetDateValue(feelings[i].date) == date.DayOfYear) // { // currentDateValue += (int)feelings[i].feeling.type; // continue; // } // if(currentDateValue==0) currentDateValue = (int)feelings[i].feeling.type; // Debug.Log("Table length: " + table.Count); // table.Add(GetDateValue(date), currentDateValue); // Debug.Log("tallennettava: " + feelings[i].date.DayOfYear); // date = feelings[i].date; // currentDateValue = 0; //} //CreateGraph(); CreateGraphWeek(); }
// Yes = 0; No = 1 public void Choice(int answer) { string response = (answer == 0) ? "Yes" : "No"; SaveDataContainer container = SaveDataContainer.Load(Path.Combine(Application.persistentDataPath, "responses.xml")); container.Responses.Add(new ResponseData(response, DateTime.Now)); container.Save(Path.Combine(Application.persistentDataPath, "responses.xml")); // Call the event if there are methods subscribed to it. if (ChoiceMade != null) { ChoiceMade(); } }
public void Test_LoadOrCreate() { var svd1 = new SaveDataContainer (); svd1.Path = "./savedata2/"; // 存在しない svd1.LoadOrCreate ("TestSaveDataContainer-004.txt"); svd1.Add ("Item", 1); svd1.Save ("TestSaveDataContainer-004.txt"); var svd2 = new SaveDataContainer (); svd2.Path = "./savedata2/"; svd2.Load ("TestSaveDataContainer-004.txt"); Assert.AreEqual (1, svd2.ItemCount); }
// Use this for initialization void Start() { responsePrefab = Resources.Load("ResponseData", typeof(GameObject)) as GameObject; List <ResponseData> responses = SaveDataContainer.Load( Path.Combine(Application.persistentDataPath, "responses.xml")).Responses; foreach (ResponseData response in responses) { GameObject instance = Instantiate(responsePrefab, Vector3.zero, Quaternion.identity, parent.transform); instance.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = response.timeOfResponse.ToShortDateString(); instance.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = response.response; } }
public void Save() { FeelingInterface[] feelingsArray = GameObject.FindObjectOfType <GameControllerScript>().currentFeelings; for (int j = 0; j < feelingsArray.GetLength(0); j++) { if (feelingsArray[j] == null) { continue; } saveData.date = System.DateTime.Now; saveData.feeling = feelingsArray[j] as TunneStruct; try { saveDataContainer = SaveDataContainer.Load(Application.persistentDataPath + "/SaveDataContainer.xml"); FeelingSaveData[] temp = saveDataContainer.SaveDataArray; saveDataContainer.SaveDataArray = new FeelingSaveData[temp.Length + 1]; for (int i = 0; i < temp.Length; i++) { saveDataContainer.SaveDataArray[i] = temp[i]; } saveDataContainer.SaveDataArray[temp.Length] = saveData; } catch (Exception e) { saveDataContainer.SaveDataArray = new FeelingSaveData[1]; saveDataContainer.SaveDataArray[0] = saveData; } try { saveDataContainer.Save(Application.persistentDataPath + "/SaveDataContainer.xml"); } catch (Exception e) { } } }
public void Test_Save_and_Load_with_Encryption() { var svd1 = new SaveDataContainer (); svd1.Encryption = true; svd1.Add ("Item", new MyStruct (1, 2f, "3")); svd1.Save ("TestSaveDataContainer-002.txt"); var svd2 = new SaveDataContainer (); svd2.Encryption = true; svd2.Load ("TestSaveDataContainer-002.txt"); Assert.AreEqual (1, svd2.ItemCount); Assert.AreEqual (new MyStruct (1, 2f, "3"), svd2.Get ("Item")); }