private void DeleteOldSaves(string _path) { string serverDatas = ""; string[] files = Directory.GetFiles(_path); foreach (string file in files) { //select .json files if (file.EndsWith(".json")) { File.Delete(file); File.Delete(file + ".meta"); } } //request playfab server var getRequest = new PlayFab.ServerModels.GetTitleDataRequest(); PlayFabServerAPI.GetTitleData(getRequest, (result) => { foreach (var entry in result.Data) { if (string.Compare(entry.Key, "Achievements") == 0) { //create a new save file with playfab datas serverDatas = entry.Value; AchievementEditor.PushToLocalJSON(serverDatas, _path); } } }, (error) => { Debug.Log("Got error getting titleData:"); Debug.Log(error.ErrorMessage); }); }
//renvoyer short 0 = ok, 1 = warning, 2 = critique //out Achievement qui comporte des données identiques; bool isAchievementOk(AchievementEditor newAchievement) { bool isOk = true; foreach (baseAchievement a in AchievementEditor.achievements) { if (string.Compare(newAchievement.GetName(), a.sName) == 0) { isOk = false; } } return(isOk); }
void OnGUI() { //permet de scroll pour afficher les éléments n'apparaissant pas dans la fenêtre scrollpos = EditorGUILayout.BeginScrollView(scrollpos); achievementName = EditorGUILayout.TextField("Achievement Name : ", achievementName); EditorGUILayout.Space(); //if (Achievement.IsDescriptionActive) //{ description = EditorGUILayout.TextField("Achievement Description : ", description); EditorGUILayout.Space(); //} matchingKey = EditorGUILayout.TextField(new GUIContent("Related Key : ", "Key in database where is stocked the Matching Data, none if you want to manualy unlock"), matchingKey); EditorGUILayout.Space(); matchingData = EditorGUILayout.TextField(new GUIContent("Related Data : ", "Data To check to validate the Achievement, none if you want to manualy unlock"), matchingData); EditorGUILayout.Space(); Treshold = EditorGUILayout.IntField("Treshold value : ", Treshold); EditorGUILayout.Space(); reward = EditorGUILayout.IntField("Reward value : ", reward); EditorGUILayout.Space(); achievementThumbnail = (Texture2D)EditorGUILayout.ObjectField("Thumbnail", achievementThumbnail, typeof(Texture2D), false); if (achievementThumbnail != previousThumbnail) { imageName = achievementThumbnail.name; previousThumbnail = achievementThumbnail; path = AssetDatabase.GetAssetPath(achievementThumbnail); //Debug.Log(path); } EditorGUILayout.Space(); if (GUILayout.Button("Add")) { AchievementEditor newAchievement = new AchievementEditor(achievementName, description, matchingData, matchingKey, imageName, Treshold, reward, path); // mettre en place 3 possibilités pour le isAchievementOk : // 1 : Il est bon // => popUp voullez vous valider [oui / non] close. // 2 : Des données importantes sont identiques à un achievement existant (image/description/matchingData) // => popUp message Warning [la donnée **nomDeLaDonée* correspond a celle de l'achievement *achievementName* voullez vous quand même valider ? [oui / non] ] // 3 : Des données critiques sont identiques à un achievement existant(Nom) // => popUp message Alert [Un achievement porte déjà le même nom veuillez changer le nom [OK] ] if (isAchievementOk(newAchievement)) { newAchievement.values.iId = AchievementEditor.achievements.Count; AchievementEditor.achievements.Add(newAchievement.values); //Debug.Log("Done"); //string jason = "\"" + newAchievement.values.sName + "\":" + EditorJsonUtility.ToJson(newAchievement.values); //Debug.Log(jason); } else { Debug.Log("OOOOOOOOOOOOOOOOH"); EditorGUILayout.HelpBox("This achievement already exist", MessageType.Warning); } } EditorGUILayout.Space(); if (GUILayout.Button("Clear List")) { ClearAchievementList(); } EditorGUILayout.EndScrollView(); }
private void OnGUI() { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); EditorGUILayout.BeginHorizontal(); if (!add) { add = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/TestPlayFab/AchievementSystem/Editor/Resources/plus.png", typeof(Texture)); } if (GUILayout.Button(add, GUILayout.Width(64), GUILayout.Height(64))) { if (!creator) { creator = new AchievementsCreator(); creator.Display(); } } if (AchievementEditor.achievements.Count != 0) { if (achievementsTexture == null || achievementsTexture.Length < AchievementEditor.achievements.Count) { achievementsTexture = new Texture2D[AchievementEditor.achievements.Count]; } for (int i = 0; i < AchievementEditor.achievements.Count; i++) { if (!achievementsTexture[i]) { achievementsTexture[i] = (Texture2D)AssetDatabase.LoadAssetAtPath(AchievementEditor.achievements[i].sPath, typeof(Texture)); } if (GUILayout.Button(achievementsTexture[i], GUILayout.Width(64), GUILayout.Height(64))) { AchievementEditor.EditorDisplay(AchievementEditor.achievements[i]); } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save to PlayFab", GUILayout.Width(128), GUILayout.Height(20))) { AchievementEditor.PushToPlayFab(position); } else if (GUILayout.Button("Load From Playfab", GUILayout.Width(128), GUILayout.Height(20))) { AchievementEditor.LoadFromPlayfab(position); } else if (GUILayout.Button("Clear list", GUILayout.Width(128), GUILayout.Height(20))) { AchievementEditor.ClearList(); } else if (GUILayout.Button("Save to Local", GUILayout.Width(128), GUILayout.Height(20))) { folderPath = EditorUtility.OpenFolderPanel("Select destination folder", folderPath, ""); if (folderPath != string.Empty) { AchievementEditor.PushToLocalJSON(folderPath); } } else if (GUILayout.Button("Load from Local", GUILayout.Width(128), GUILayout.Height(20))) { filePath = EditorUtility.OpenFilePanel("Select destination folder", filePath, "json"); if (filePath != string.Empty) { AchievementEditor.LoadFromLocalJSON(filePath); } } EditorGUILayout.EndHorizontal(); }
public AchievementEditor CreatFromJSON(string JSONObject) { AchievementEditor toReturn = new AchievementEditor(); return(toReturn); }