From 73a88729b9414dbf6c46e9d2b8e582c1896cffa5 Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Mon, 12 Feb 2024 11:12:28 +0200 Subject: [PATCH 1/4] chore: add path check --- Editor/Core/Scripts/Settings/CoreSettingsLoader.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs index 088350e2..26d4f925 100644 --- a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs +++ b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs @@ -9,15 +9,15 @@ public static class CoreSettingsLoader { private const string PROJECT_RELATIVE_ASSET_PATH = "Assets/Ready Player Me/Resources/Settings/CoreSettings.asset"; private const string SETTINGS_SAVE_FOLDER = "Ready Player Me/Resources/Settings"; - + static CoreSettingsLoader() { EnsureSettingsExist(); } - + public static void EnsureSettingsExist() { - if (CoreSettingsHandler.CoreSettings == null) + if (CoreSettingsHandler.CoreSettings == null && AssetDatabase.LoadAssetAtPath(PROJECT_RELATIVE_ASSET_PATH) == null) { CreateSettings(); } @@ -32,4 +32,4 @@ private static void CreateSettings() AssetDatabase.Refresh(); } } -} \ No newline at end of file +} From 40369ff8e62361773c162ea9404ea3eb60884b35 Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Wed, 14 Feb 2024 11:06:34 +0200 Subject: [PATCH 2/4] chore: add debug --- Editor/Core/Scripts/Settings/CoreSettingsLoader.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs index 26d4f925..a726b49e 100644 --- a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs +++ b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs @@ -25,6 +25,7 @@ public static void EnsureSettingsExist() private static void CreateSettings() { + Debug.Log($"Create Seed Settings at {PROJECT_RELATIVE_ASSET_PATH}"); DirectoryUtility.ValidateDirectory($"{Application.dataPath}/{SETTINGS_SAVE_FOLDER}"); var newSettings = ScriptableObject.CreateInstance(); AssetDatabase.CreateAsset(newSettings, PROJECT_RELATIVE_ASSET_PATH); From 618ff5f3f784efda291b46a7fafbae5ff854a266 Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Wed, 14 Feb 2024 11:10:16 +0200 Subject: [PATCH 3/4] chore: add extra check --- Editor/Core/Scripts/Settings/CoreSettingsLoader.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs index a726b49e..b23f46cb 100644 --- a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs +++ b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs @@ -1,3 +1,4 @@ +using System.IO; using ReadyPlayerMe.Core.Data; using UnityEditor; using UnityEngine; @@ -25,7 +26,14 @@ public static void EnsureSettingsExist() private static void CreateSettings() { - Debug.Log($"Create Seed Settings at {PROJECT_RELATIVE_ASSET_PATH}"); + + if (Directory.Exists($"{Application.dataPath}/{SETTINGS_SAVE_FOLDER}")) + { + Debug.Log($"Settings exist {PROJECT_RELATIVE_ASSET_PATH} skipping"); + return; + } + Debug.Log($"Settings not found at {Application.dataPath}/{PROJECT_RELATIVE_ASSET_PATH}"); + DirectoryUtility.ValidateDirectory($"{Application.dataPath}/{SETTINGS_SAVE_FOLDER}"); var newSettings = ScriptableObject.CreateInstance(); AssetDatabase.CreateAsset(newSettings, PROJECT_RELATIVE_ASSET_PATH); From 6f32c3738625daaeec881bb30a81aaa9419a00f2 Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Wed, 14 Feb 2024 11:14:59 +0200 Subject: [PATCH 4/4] chore: simplify check --- Editor/Core/Scripts/Settings/CoreSettingsLoader.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs index b23f46cb..87051658 100644 --- a/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs +++ b/Editor/Core/Scripts/Settings/CoreSettingsLoader.cs @@ -18,7 +18,7 @@ static CoreSettingsLoader() public static void EnsureSettingsExist() { - if (CoreSettingsHandler.CoreSettings == null && AssetDatabase.LoadAssetAtPath(PROJECT_RELATIVE_ASSET_PATH) == null) + if (CoreSettingsHandler.CoreSettings == null && !File.Exists($"{Application.dataPath}/Ready Player Me/Resources/Settings/CoreSettings.asset")) { CreateSettings(); } @@ -26,14 +26,6 @@ public static void EnsureSettingsExist() private static void CreateSettings() { - - if (Directory.Exists($"{Application.dataPath}/{SETTINGS_SAVE_FOLDER}")) - { - Debug.Log($"Settings exist {PROJECT_RELATIVE_ASSET_PATH} skipping"); - return; - } - Debug.Log($"Settings not found at {Application.dataPath}/{PROJECT_RELATIVE_ASSET_PATH}"); - DirectoryUtility.ValidateDirectory($"{Application.dataPath}/{SETTINGS_SAVE_FOLDER}"); var newSettings = ScriptableObject.CreateInstance(); AssetDatabase.CreateAsset(newSettings, PROJECT_RELATIVE_ASSET_PATH);