public static void WriteToFile(object data, string filename) { string outString = DiagJson.Serialize(data); File.WriteAllText(fileDataPath + filename, outString); }
public static void SaveLanguages(string currentDiag) { #if UNITY_EDITOR Dictionary <string, object> dict = new Dictionary <string, object>(); List <string> sameNames = new List <string>(); for (int d = 0; d < languages.Count; d++) { string lang = languages[d].name + "_"; if (!sameNames.Contains(lang)) { sameNames.Add(lang); } else { continue; } if (languages[d].playerDiags != null) { dict.Add(lang + "playerDiags", languages[d].playerDiags.Count); } if (languages[d].playerDiags != null) { for (int i = 0; i < languages[d].playerDiags.Count; i++) { dict.Add(lang + "pd_pTag_" + i.ToString(), languages[d].playerDiags[i].playerTag); dict.Add(lang + "pd_comSize_" + i.ToString(), languages[d].playerDiags[i].comment.Count); if (languages[d].playerDiags[i].sprite != null) { dict.Add(lang + "pd_sprite_" + i.ToString(), UnityEditor.AssetDatabase.GetAssetPath(languages[d].playerDiags[i].sprite)); } else { dict.Add(lang + "pd_sprite_" + i.ToString(), string.Empty); } for (int ii = 0; ii < languages[d].playerDiags[i].comment.Count; ii++) { dict.Add(lang + "pd_" + i.ToString() + "_com_" + ii.ToString() + "text", languages[d].playerDiags[i].comment[ii].text); if (languages[d].playerDiags[i].comment[ii].audios != null) { dict.Add(lang + "pd_" + i.ToString() + "_com_" + ii.ToString() + "audio", UnityEditor.AssetDatabase.GetAssetPath(languages[d].playerDiags[i].comment[ii].audios)); } else { dict.Add(lang + "pd_" + i.ToString() + "_com_" + ii.ToString() + "audio", string.Empty); } if (languages[d].playerDiags[i].comment[ii].sprites != null) { dict.Add(lang + "pd_" + i.ToString() + "_com_" + ii.ToString() + "sprite", UnityEditor.AssetDatabase.GetAssetPath(languages[d].playerDiags[i].comment[ii].sprites)); } else { dict.Add(lang + "pd_" + i.ToString() + "_com_" + ii.ToString() + "sprite", string.Empty); } } } } } string fileDataPath = Application.dataPath + "/../" + VIDE_EditorDB.videRoot + "/Resources/Localized/"; string outString = DiagJson.Serialize(dict as Dictionary <string, object>); File.WriteAllText(fileDataPath + "LOC_" + currentDiag + ".json", outString); #endif }