Working synchronous Addressables settings loading

This commit is contained in:
Michal Pikulski
2025-09-23 15:30:21 +02:00
parent 197aedddb0
commit 404f6f4e5c
4 changed files with 97 additions and 75 deletions

View File

@@ -10,7 +10,6 @@ namespace AppleHills.Editor
public class SettingsMigrationWindow : EditorWindow
{
private GameSettings legacySettings;
private bool settingsFolderExists;
private bool addressablesInstalled;
private AddressableAssetSettings addressableSettings;
private AddressableAssetGroup settingsGroup;
@@ -19,7 +18,7 @@ namespace AppleHills.Editor
private Vector2 scrollPosition;
private bool migrationCompleted = false;
[MenuItem("AppleHills/Migrate Legacy Settings")]
[MenuItem("Tools/Migrate Legacy Settings")]
public static void ShowWindow()
{
var window = GetWindow<SettingsMigrationWindow>("Settings Migration");
@@ -28,9 +27,6 @@ namespace AppleHills.Editor
private void OnEnable()
{
// Check if Settings folder exists
settingsFolderExists = AssetDatabase.IsValidFolder("Assets/Settings");
// Check if Addressables package is installed
addressablesInstalled = AddressableAssetSettingsDefaultObject.SettingsExists;
@@ -60,8 +56,7 @@ namespace AppleHills.Editor
EditorGUILayout.HelpBox(
"This tool will migrate your legacy GameSettings to the new modular settings system. " +
"It will create new settings assets in the Assets/Settings folder, mark them as Addressables, " +
"and copy values from your legacy settings.",
"It will create new settings assets and mark them as Addressables for synchronous loading at runtime.",
MessageType.Info);
EditorGUILayout.Space(10);
@@ -112,7 +107,8 @@ namespace AppleHills.Editor
EditorGUILayout.LabelField("Migration completed successfully!", successStyle);
EditorGUILayout.HelpBox(
"The legacy settings have been migrated to the new system. " +
"You can now access these settings through the AppleHills > Settings Editor menu.",
"You can now access these settings through the AppleHills > Settings Editor menu. " +
"Settings are marked as Addressables and will load synchronously at runtime.",
MessageType.Info);
}
@@ -122,10 +118,9 @@ namespace AppleHills.Editor
private void MigrateSettings()
{
// Create Settings folder if it doesn't exist
if (!settingsFolderExists)
if (!AssetDatabase.IsValidFolder("Assets/Settings"))
{
AssetDatabase.CreateFolder("Assets", "Settings");
settingsFolderExists = true;
}
// Setup Addressables group for settings
@@ -159,7 +154,7 @@ namespace AppleHills.Editor
var guid = AssetDatabase.AssetPathToGUID(assetPath);
var entry = addressableSettings.CreateOrMoveEntry(guid, settingsGroup);
// Set the address
// Set the address - use without .asset extension for cleaner addresses
entry.address = address;
Debug.Log($"Added {assetPath} to Addressables with address {address}");