diff --git a/Basis/Packages/com.basis.framework/UI Panels/BasisDataStoreAvatarKeys.cs b/Basis/Packages/com.basis.framework/UI Panels/BasisDataStoreAvatarKeys.cs index be3c12289..50c207ae6 100644 --- a/Basis/Packages/com.basis.framework/UI Panels/BasisDataStoreAvatarKeys.cs +++ b/Basis/Packages/com.basis.framework/UI Panels/BasisDataStoreAvatarKeys.cs @@ -1,4 +1,5 @@ using BasisSerializer.OdinSerializer; +using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -14,8 +15,13 @@ public class AvatarKey public string Url; public string Pass; } +#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + private static string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Application.companyName, Application.productName); + public static string FilePath = Path.Combine(directory, "KeyStore.json"); +#else public static string FilePath = Path.Combine(Application.persistentDataPath, "KeyStore.json"); - + +#endif [SerializeField] private static List keys = new List(); @@ -63,6 +69,17 @@ public static async Task LoadKeys() else { BasisDebug.Log("No key file found. Starting fresh."); +#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + string checkMigration = Path.Combine(Application.persistentDataPath, "KeyStore.json"); + if (File.Exists(checkMigration)) + { + File.Copy(checkMigration, FilePath); + } +#endif } } @@ -70,6 +87,12 @@ private static async Task SaveKeysToFile() { try { +#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } +#endif byte[] byteData = SerializationUtility.SerializeValue>(keys, DataFormat.Binary); await File.WriteAllBytesAsync(FilePath, byteData); BasisDebug.Log($"Keys saved to file at: {FilePath}"); @@ -77,6 +100,9 @@ private static async Task SaveKeysToFile() catch (System.Exception e) { BasisDebug.LogError($"Failed to save keys: {e.Message}"); + if (File.Exists(FilePath)) { + File.Copy(FilePath, Path.ChangeExtension(FilePath, ".json.bak")); + } } } diff --git a/Basis/Packages/com.basis.sdk/Scripts/Editor/BasisAvatarValidator.cs b/Basis/Packages/com.basis.sdk/Scripts/Editor/BasisAvatarValidator.cs index f2b2f0ef0..c4b9dc37a 100644 --- a/Basis/Packages/com.basis.sdk/Scripts/Editor/BasisAvatarValidator.cs +++ b/Basis/Packages/com.basis.sdk/Scripts/Editor/BasisAvatarValidator.cs @@ -488,7 +488,7 @@ public static bool ReportIfNoIll2CPP() } private void ShowErrorPanel(VisualElement Root, List errors) { - string IssueList = string.Empty; + List IssueList = new List(); for (int Index = 0; Index < errors.Count; Index++) { BasisValidationIssue issue = errors[Index]; @@ -497,9 +497,12 @@ private void ShowErrorPanel(VisualElement Root, List error { AutoFixButton(Root, ActFix, issue.Message); } - IssueList += issue.Message; + if (!IssueList.Exists(i => i == issue.Message)) + { + IssueList.Add(issue.Message); + } } - errorMessageLabel.text = string.Join("\n", IssueList); + errorMessageLabel.text = string.Join("\n", IssueList.ToArray()); errorPanel.style.display = DisplayStyle.Flex; } private void HideErrorPanel() @@ -508,7 +511,7 @@ private void HideErrorPanel() } private void ShowWarningPanel(VisualElement Root,List warnings) { - string warningsList = string.Empty; + List warningsList = new List(); for (int Index = 0; Index < warnings.Count; Index++) { BasisValidationIssue issue = warnings[Index]; @@ -517,9 +520,12 @@ private void ShowWarningPanel(VisualElement Root,List warn { AutoFixButton(Root, ActFix, issue.Message); } - warningsList += issue.Message; + if (!warningsList.Exists(i => i==issue.Message)) + { + warningsList.Add(issue.Message); + } } - warningMessageLabel.text = string.Join("\n", warningsList); + warningMessageLabel.text = string.Join("\n", warningsList.ToArray()); warningPanel.style.display = DisplayStyle.Flex; } public void ClearFixButtons(VisualElement rootElement)