diff --git a/Assets/AddressableAssetsData/AddressableAssetGroupSortSettings.asset b/Assets/AddressableAssetsData/AddressableAssetGroupSortSettings.asset
index 83bb861d..b4233d0d 100644
--- a/Assets/AddressableAssetsData/AddressableAssetGroupSortSettings.asset
+++ b/Assets/AddressableAssetsData/AddressableAssetGroupSortSettings.asset
@@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: AddressableAssetGroupSortSettings
m_EditorClassIdentifier:
sortOrder:
+ - 0d5d36d6da388314b92b9c6967d23f39
- 75e1f68b7bf77f34f8ad4aeab74d4244
- eb8a37153d819c44194f7ce97570a3d3
- 2b3d7cefec0915e42be04aebf0400a56
diff --git a/Assets/AddressableAssetsData/AddressableAssetSettings.asset b/Assets/AddressableAssetsData/AddressableAssetSettings.asset
index 707a8f4c..021e9892 100644
--- a/Assets/AddressableAssetsData/AddressableAssetSettings.asset
+++ b/Assets/AddressableAssetsData/AddressableAssetSettings.asset
@@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: 6f3207429a65b3e4b83935ac19791077
m_currentHash:
serializedVersion: 2
- Hash: 58bff643ea54adc47e3181c09b68468c
+ Hash: 00000000000000000000000000000000
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0
m_CatalogRequestsTimeout: 0
@@ -60,6 +60,7 @@ MonoBehaviour:
m_BuildAddressablesWithPlayerBuild: 0
m_overridePlayerVersion: '[UnityEditor.PlayerSettings.bundleVersion]'
m_GroupAssets:
+ - {fileID: 11400000, guid: 124f05e204489af49943d7fc039640a4, type: 2}
- {fileID: 11400000, guid: efe7e1728e73e9546ac5dfee2eff524f, type: 2}
- {fileID: 11400000, guid: 6e4927e7e19eef34b93dc2baa9e9e8e2, type: 2}
- {fileID: 11400000, guid: 4186fdd83f912a14b97fbf4644266b0d, type: 2}
@@ -104,6 +105,7 @@ MonoBehaviour:
m_LabelTable:
m_LabelNames:
- default
+ - BlokkemonCard
m_SchemaTemplates: []
m_GroupTemplateObjects:
- {fileID: 11400000, guid: ea0a5135f5495eb4693a23d94617fe92, type: 2}
diff --git a/Assets/AddressableAssetsData/AssetGroups/BlokkemonCards.asset b/Assets/AddressableAssetsData/AssetGroups/BlokkemonCards.asset
new file mode 100644
index 00000000..a13c2f31
--- /dev/null
+++ b/Assets/AddressableAssetsData/AssetGroups/BlokkemonCards.asset
@@ -0,0 +1,71 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
+ m_Name: BlokkemonCards
+ m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.AddressableAssetGroup
+ m_GroupName: BlokkemonCards
+ m_GUID: 0d5d36d6da388314b92b9c6967d23f39
+ m_SerializeEntries:
+ - m_GUID: 28dbfbd7a6b2cd84b8274bd1126b220b
+ m_Address: Assets/Data/Cards/Card_Test example card 2 (Copy).asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: 4b9c8b6ca63744a44acfe49ebe337619
+ m_Address: Assets/Data/Cards/Card_New Card 2.asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: 5d8121cdf52bfe9488b40ed22d649209
+ m_Address: Assets/Data/Cards/Card_New Card 1.asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: 6afed7a67f64404418f905e7808bf5cb
+ m_Address: Assets/Data/Cards/Card_Test example card 3 (Copy).asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: 8f02c3699de87014bac8c03b96772a4b
+ m_Address: Assets/Data/Cards/Card_Test example card (Copy).asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: 8fdeae7881d130f408e0f31c101ab41f
+ m_Address: Assets/Data/Cards/Card_Test example card (Copy) 1.asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: 91031de62f795884e8e2ccbaebeebf9b
+ m_Address: Assets/Data/Cards/Card_New Card.asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ - m_GUID: dec49537f6ae6d241acf8275eaa6c653
+ m_Address: Assets/Data/Cards/Card_Test example card 2 (Copy) 1.asset
+ m_ReadOnly: 0
+ m_SerializedLabels:
+ - BlokkemonCard
+ FlaggedDuringContentUpdateRestriction: 0
+ m_ReadOnly: 0
+ m_Settings: {fileID: 11400000, guid: 11da9bb90d9dd5848b4f7629415a6937, type: 2}
+ m_SchemaSet:
+ m_Schemas:
+ - {fileID: 11400000, guid: a0affac7520cbac4283e5d0fe0c0d28a, type: 2}
+ - {fileID: 11400000, guid: ca0e74b531acf5449a15f65103061116, type: 2}
diff --git a/Assets/AddressableAssetsData/AssetGroups/BlokkemonCards.asset.meta b/Assets/AddressableAssetsData/AssetGroups/BlokkemonCards.asset.meta
new file mode 100644
index 00000000..1e8cfc4e
--- /dev/null
+++ b/Assets/AddressableAssetsData/AssetGroups/BlokkemonCards.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 124f05e204489af49943d7fc039640a4
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_BundledAssetGroupSchema.asset b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_BundledAssetGroupSchema.asset
new file mode 100644
index 00000000..7c18d304
--- /dev/null
+++ b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_BundledAssetGroupSchema.asset
@@ -0,0 +1,48 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3}
+ m_Name: BlokkemonCards_BundledAssetGroupSchema
+ m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.BundledAssetGroupSchema
+ m_Group: {fileID: 11400000, guid: 124f05e204489af49943d7fc039640a4, type: 2}
+ m_InternalBundleIdMode: 1
+ m_Compression: 1
+ m_IncludeAddressInCatalog: 1
+ m_IncludeGUIDInCatalog: 1
+ m_IncludeLabelsInCatalog: 1
+ m_InternalIdNamingMode: 0
+ m_CacheClearBehavior: 0
+ m_IncludeInBuild: 1
+ m_BundledAssetProviderType:
+ m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+ m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider
+ m_StripDownloadOptions: 0
+ m_ForceUniqueProvider: 0
+ m_UseAssetBundleCache: 1
+ m_UseAssetBundleCrc: 1
+ m_UseAssetBundleCrcForCachedBundles: 1
+ m_UseUWRForLocalBundles: 0
+ m_Timeout: 0
+ m_ChunkedTransfer: 0
+ m_RedirectLimit: -1
+ m_RetryCount: 0
+ m_BuildPath:
+ m_Id: c258e2bcd3e8ac742ba98f152c0e6322
+ m_LoadPath:
+ m_Id: 88323bf0b2ef98446961cedd6232bd47
+ m_BundleMode: 0
+ m_AssetBundleProviderType:
+ m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
+ m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
+ m_UseDefaultSchemaSettings: 0
+ m_SelectedPathPairIndex: 0
+ m_BundleNaming: 0
+ m_AssetLoadMode: 0
diff --git a/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_BundledAssetGroupSchema.asset.meta b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_BundledAssetGroupSchema.asset.meta
new file mode 100644
index 00000000..35c415c3
--- /dev/null
+++ b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_BundledAssetGroupSchema.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a0affac7520cbac4283e5d0fe0c0d28a
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_ContentUpdateGroupSchema.asset b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_ContentUpdateGroupSchema.asset
new file mode 100644
index 00000000..c320f49f
--- /dev/null
+++ b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_ContentUpdateGroupSchema.asset
@@ -0,0 +1,16 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
+ m_Name: BlokkemonCards_ContentUpdateGroupSchema
+ m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.ContentUpdateGroupSchema
+ m_Group: {fileID: 11400000, guid: 124f05e204489af49943d7fc039640a4, type: 2}
+ m_StaticContent: 0
diff --git a/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_ContentUpdateGroupSchema.asset.meta b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_ContentUpdateGroupSchema.asset.meta
new file mode 100644
index 00000000..1e5923ae
--- /dev/null
+++ b/Assets/AddressableAssetsData/AssetGroups/Schemas/BlokkemonCards_ContentUpdateGroupSchema.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: ca0e74b531acf5449a15f65103061116
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Data/Cards/Card_New Card 2.asset b/Assets/Data/Cards/Card_New Card 2.asset
new file mode 100644
index 00000000..4168fc2c
--- /dev/null
+++ b/Assets/Data/Cards/Card_New Card 2.asset
@@ -0,0 +1,21 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 2a80cc88c9884512b8b633110d838780, type: 3}
+ m_Name: Card_New Card 2
+ m_EditorClassIdentifier: AppleHillsScripts::AppleHills.Data.CardSystem.CardDefinition
+ Id: 7ea4fa95-5327-439b-ab7f-94f2656281f2
+ Name: My New Addressable Card!
+ Description: Description goes hereeee
+ Rarity: 0
+ Zone: 0
+ CardImage: {fileID: 0}
+ CollectionIndex: 7
diff --git a/Assets/Data/Cards/Card_New Card 2.asset.meta b/Assets/Data/Cards/Card_New Card 2.asset.meta
new file mode 100644
index 00000000..304b28ac
--- /dev/null
+++ b/Assets/Data/Cards/Card_New Card 2.asset.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 4b9c8b6ca63744a44acfe49ebe337619
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 11400000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Editor/Bootstrap/CustomBootSettingsUtil.cs b/Assets/Editor/Bootstrap/CustomBootSettingsUtil.cs
index ed20ac59..fcf8151f 100644
--- a/Assets/Editor/Bootstrap/CustomBootSettingsUtil.cs
+++ b/Assets/Editor/Bootstrap/CustomBootSettingsUtil.cs
@@ -1,10 +1,9 @@
using System.IO;
using System.Linq;
+using AppleHills.Editor.Utilities;
using Bootstrap;
using UnityEditor;
-using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings;
-using UnityEditor.AddressableAssets.Settings.GroupSchemas;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.AddressableAssets;
@@ -160,10 +159,15 @@ namespace Editor.Bootstrap
private static AddressableAssetEntry CreateCustomBootSettingsEntry(CustomBootSettings bootSettings,
AddressableAssetGroup group, string key)
{
- var settings = AddressableAssetSettingsDefaultObject.Settings;
- var entry = settings.CreateOrMoveEntry(
- AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(bootSettings)),
- group);
+ string assetPath = AssetDatabase.GetAssetPath(bootSettings);
+ var settings = AddressablesUtility.GetAddressableSettings(false);
+ if (settings == null || string.IsNullOrEmpty(assetPath) || group == null)
+ {
+ return null;
+ }
+
+ var guid = AssetDatabase.AssetPathToGUID(assetPath);
+ var entry = settings.CreateOrMoveEntry(guid, group);
entry.address = key;
settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entry, true);
return entry;
@@ -189,21 +193,7 @@ namespace Editor.Bootstrap
///
private static AddressableAssetGroup GetOrCreateGroup(string name, bool includeInBuild)
{
- // Use GetSettings(true) to ensure the settings asset is created if missing
- var settings = AddressableAssetSettingsDefaultObject.GetSettings(true);
- if (settings == null)
- {
- Debug.LogError("AddressableAssetSettings could not be found or created. Please ensure Addressables are set up in your project.");
- return null;
- }
- var group = settings.FindGroup(name);
- if (group == null)
- {
- group = settings.CreateGroup(name, false, false, true, settings.DefaultGroup.Schemas);
- group.GetSchema().IncludeInBuild = includeInBuild;
- }
-
- return group;
+ return AddressablesUtility.GetOrCreateGroup(name, includeInBuild);
}
///
diff --git a/Assets/Editor/CardSystem/CardEditorWindow.cs b/Assets/Editor/CardSystem/CardEditorWindow.cs
index 52c5e47e..5e7b0618 100644
--- a/Assets/Editor/CardSystem/CardEditorWindow.cs
+++ b/Assets/Editor/CardSystem/CardEditorWindow.cs
@@ -4,8 +4,10 @@ using System.Linq;
using AppleHills.Data.CardSystem;
using AppleHills.UI.CardSystem;
using UnityEditor;
+using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
using UnityEngine.UI;
+using AppleHills.Editor.Utilities;
namespace AppleHills.Editor.CardSystem
{
@@ -1078,7 +1080,20 @@ namespace AppleHills.Editor.CardSystem
// Mark as dirty and save
EditorUtility.SetDirty(_selectedCard);
AssetDatabase.SaveAssets();
-
+
+ // Add to Addressables group "BlokkemonCards" and apply "BlokkemonCard" label
+ string assetPath = AssetDatabase.GetAssetPath(_selectedCard);
+ if (!string.IsNullOrEmpty(assetPath))
+ {
+ if (AddressablesUtility.EnsureAssetInGroupWithLabel(assetPath, "BlokkemonCards", "BlokkemonCard"))
+ {
+ AddressablesUtility.SaveAddressableAssets();
+ }
+ else
+ {
+ Debug.LogError("Failed to add card to Addressables. Please ensure Addressables are set up in this project.");
+ }
+ }
// Clear dirty flag
_isDirty = false;
}
diff --git a/Assets/Editor/Utilities/AddressablesUtility.cs b/Assets/Editor/Utilities/AddressablesUtility.cs
new file mode 100644
index 00000000..0bb65d78
--- /dev/null
+++ b/Assets/Editor/Utilities/AddressablesUtility.cs
@@ -0,0 +1,226 @@
+using UnityEditor.AddressableAssets;
+using UnityEditor.AddressableAssets.Settings;
+using UnityEditor.AddressableAssets.Settings.GroupSchemas;
+using UnityEngine;
+using UnityEditor;
+
+namespace AppleHills.Editor.Utilities
+{
+ ///
+ /// Utility methods for working with the Addressables system in editor scripts.
+ /// Contains common operations for creating and managing groups and entries.
+ ///
+ public static class AddressablesUtility
+ {
+ ///
+ /// Get or create the Addressables settings. Returns null if Addressables are not properly set up.
+ ///
+ /// If true, will attempt to create settings if they don't exist
+ /// The AddressableAssetSettings or null if not available
+ public static AddressableAssetSettings GetAddressableSettings(bool createIfMissing = false)
+ {
+ var settings = AddressableAssetSettingsDefaultObject.GetSettings(createIfMissing);
+ if (settings == null && createIfMissing)
+ {
+ Debug.LogError("AddressableAssetSettings could not be found or created. Please ensure Addressables are set up in your project.");
+ }
+ return settings;
+ }
+
+ ///
+ /// Retrieve or create an Addressables group.
+ ///
+ /// Name of the group
+ /// Whether to include assets in this group when building
+ /// The created or existing group, or null if settings aren't available
+ public static AddressableAssetGroup GetOrCreateGroup(string name, bool includeInBuild = true)
+ {
+ // Use GetSettings(true) to ensure the settings asset is created if missing
+ var settings = GetAddressableSettings(true);
+ if (settings == null)
+ {
+ return null;
+ }
+
+ var group = settings.FindGroup(name);
+ if (group == null)
+ {
+ group = settings.CreateGroup(name, false, false, true, settings.DefaultGroup.Schemas);
+
+ // Configure the bundle schema if it exists
+ var bundleSchema = group.GetSchema();
+ if (bundleSchema != null)
+ {
+ bundleSchema.IncludeInBuild = includeInBuild;
+ }
+ }
+
+ return group;
+ }
+
+ ///
+ /// Create or move an asset entry to a specified Addressables group
+ ///
+ /// Path to the asset
+ /// Name of the group to add the asset to
+ /// Optional custom address for the asset
+ /// The created or moved asset entry, or null if failed
+ public static AddressableAssetEntry AddAssetToGroup(string assetPath, string groupName, string address = null)
+ {
+ if (string.IsNullOrEmpty(assetPath))
+ {
+ Debug.LogError("Cannot add asset to Addressables: Asset path is empty");
+ return null;
+ }
+
+ var settings = GetAddressableSettings(false);
+ if (settings == null)
+ {
+ return null;
+ }
+
+ var group = GetOrCreateGroup(groupName);
+ if (group == null)
+ {
+ return null;
+ }
+
+ var guid = AssetDatabase.AssetPathToGUID(assetPath);
+ if (string.IsNullOrEmpty(guid))
+ {
+ Debug.LogError($"Cannot add asset to Addressables: Invalid asset path {assetPath}");
+ return null;
+ }
+
+ var entry = settings.CreateOrMoveEntry(guid, group);
+
+ // Set custom address if provided
+ if (!string.IsNullOrEmpty(address))
+ {
+ entry.address = address;
+ }
+
+ settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entry, true);
+ return entry;
+ }
+
+ ///
+ /// Ensure an asset is in the specified addressable group
+ ///
+ /// Path to the asset
+ /// Target group name
+ /// Whether to mark settings as dirty
+ /// True if the asset is now in the correct group
+ public static bool EnsureAssetInGroup(string assetPath, string groupName, bool markDirty = true)
+ {
+ var settings = GetAddressableSettings(false);
+ if (settings == null)
+ {
+ return false;
+ }
+
+ var guid = AssetDatabase.AssetPathToGUID(assetPath);
+ if (string.IsNullOrEmpty(guid))
+ {
+ return false;
+ }
+
+ var group = GetOrCreateGroup(groupName);
+ if (group == null)
+ {
+ return false;
+ }
+
+ var entry = settings.FindAssetEntry(guid);
+
+ // If entry exists but is in wrong group, move it
+ if (entry != null && entry.parentGroup != group)
+ {
+ settings.MoveEntry(entry, group);
+ if (markDirty)
+ {
+ settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entry, true);
+ }
+ return true;
+ }
+ // If entry doesn't exist, create it
+ else if (entry == null)
+ {
+ entry = settings.CreateOrMoveEntry(guid, group);
+ if (markDirty)
+ {
+ settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryAdded, entry, true);
+ }
+ return true;
+ }
+
+ // Entry already exists in correct group
+ return true;
+ }
+
+ ///
+ /// Save any pending changes to addressable assets
+ ///
+ public static void SaveAddressableAssets()
+ {
+ AssetDatabase.SaveAssets();
+ }
+
+ ///
+ /// Add a label to an addressable asset
+ ///
+ /// Path to the asset
+ /// Label to add
+ /// True if the label was successfully added
+ public static bool AddLabelToAsset(string assetPath, string label)
+ {
+ if (string.IsNullOrEmpty(assetPath) || string.IsNullOrEmpty(label))
+ {
+ return false;
+ }
+
+ var settings = GetAddressableSettings(false);
+ if (settings == null)
+ {
+ return false;
+ }
+
+ var guid = AssetDatabase.AssetPathToGUID(assetPath);
+ var entry = settings.FindAssetEntry(guid);
+
+ if (entry == null)
+ {
+ Debug.LogWarning($"Asset at {assetPath} is not addressable. Add it to a group first before applying labels.");
+ return false;
+ }
+
+ // Make sure the label exists in the settings
+ if (!settings.GetLabels().Contains(label))
+ {
+ settings.AddLabel(label);
+ }
+
+ // Add the label to the entry
+ entry.labels.Add(label);
+ settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryModified, entry, true);
+ return true;
+ }
+
+ ///
+ /// Ensure an asset is in an addressable group and has the specified label
+ ///
+ /// Path to the asset
+ /// Group to add the asset to
+ /// Label to apply to the asset
+ /// True if the asset was successfully added to the group and labeled
+ public static bool EnsureAssetInGroupWithLabel(string assetPath, string groupName, string label)
+ {
+ bool result = EnsureAssetInGroup(assetPath, groupName);
+ if (result && !string.IsNullOrEmpty(label))
+ {
+ result = AddLabelToAsset(assetPath, label);
+ }
+ return result;
+ }
+ }
+}
diff --git a/Assets/Editor/Utilities/AddressablesUtility.cs.meta b/Assets/Editor/Utilities/AddressablesUtility.cs.meta
new file mode 100644
index 00000000..8ddd4906
--- /dev/null
+++ b/Assets/Editor/Utilities/AddressablesUtility.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 5225b0b6611c4dc7a6e1f48919831efd
+timeCreated: 1761029089
\ No newline at end of file
diff --git a/Assets/Resources/Fonts/Æblerup Font/AppleHills03 SDF.asset b/Assets/Resources/Fonts/Æblerup Font/AppleHills03 SDF.asset
index 12dbe09e..d658ac16 100644
--- a/Assets/Resources/Fonts/Æblerup Font/AppleHills03 SDF.asset
+++ b/Assets/Resources/Fonts/Æblerup Font/AppleHills03 SDF.asset
@@ -287,10 +287,10 @@ Texture2D:
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
- m_ColorSpace: 1
+ m_ColorSpace: 0
m_PlatformBlob:
image data: 1
- _typelessdata: cd
+ _typelessdata: 00
m_StreamData:
serializedVersion: 2
offset: 0
diff --git a/Assets/Resources/Fonts/Æblerup Font/AppleHills04 SDF.asset b/Assets/Resources/Fonts/Æblerup Font/AppleHills04 SDF.asset
index c19cc3b9..711aa0e5 100644
--- a/Assets/Resources/Fonts/Æblerup Font/AppleHills04 SDF.asset
+++ b/Assets/Resources/Fonts/Æblerup Font/AppleHills04 SDF.asset
@@ -146,10 +146,10 @@ Texture2D:
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
- m_ColorSpace: 1
+ m_ColorSpace: 0
m_PlatformBlob:
image data: 1
- _typelessdata: cd
+ _typelessdata: 00
m_StreamData:
serializedVersion: 2
offset: 0
diff --git a/Assets/Scripts/Data/CardSystem/CardDefinition.cs b/Assets/Scripts/Data/CardSystem/CardDefinition.cs
index 318579df..23dfe90a 100644
--- a/Assets/Scripts/Data/CardSystem/CardDefinition.cs
+++ b/Assets/Scripts/Data/CardSystem/CardDefinition.cs
@@ -57,5 +57,19 @@ namespace AppleHills.Data.CardSystem
return Color.white;
}
}
+
+ public override bool Equals(object obj)
+ {
+ if (obj is CardDefinition other)
+ {
+ return string.Equals(Id, other.Id, StringComparison.Ordinal);
+ }
+ return false;
+ }
+
+ public override int GetHashCode()
+ {
+ return Id != null ? Id.GetHashCode() : 0;
+ }
}
}
diff --git a/Assets/Scripts/Data/CardSystem/CardSystemManager.cs b/Assets/Scripts/Data/CardSystem/CardSystemManager.cs
index 7ced670a..7fe77c27 100644
--- a/Assets/Scripts/Data/CardSystem/CardSystemManager.cs
+++ b/Assets/Scripts/Data/CardSystem/CardSystemManager.cs
@@ -23,17 +23,13 @@ namespace Data.CardSystem
[Header("Card Collection")]
[SerializeField] private List availableCards = new List();
-
- [Header("Auto-Loading Configuration")]
- [SerializeField] private bool autoLoadCardDefinitions = true;
- [SerializeField] private string cardDataPath = "Data/Cards";
-
+
// Runtime data - will be serialized for save/load
[SerializeField] private CardInventory playerInventory = new CardInventory();
-
+
// Dictionary to quickly look up card definitions by ID
private Dictionary _definitionLookup = new Dictionary();
-
+
// Event callbacks using System.Action
public event Action> OnBoosterOpened;
public event Action OnCardCollected;
@@ -43,23 +39,19 @@ namespace Data.CardSystem
private void Awake()
{
_instance = this;
-
- // Auto-load card definitions if enabled
- if (autoLoadCardDefinitions)
- {
- LoadCardDefinitionsFromFolder();
- }
+
+ // Register for post-boot initialization
+ BootCompletionService.RegisterInitAction(InitializePostBoot);
+ }
+
+ private void InitializePostBoot()
+ {
+ // Load card definitions from Addressables
+ LoadCardDefinitionsFromAddressables();
// Build lookup dictionary
BuildDefinitionLookup();
- // Register for post-boot initialization
- BootCompletionService.RegisterInitAction(InitializePostBoot);
- }
-
- private void InitializePostBoot()
- {
- // Initialize any dependencies that require other services to be ready
Logging.Debug("[CardSystemManager] Post-boot initialization complete");
}
@@ -67,46 +59,35 @@ namespace Data.CardSystem
{
_isQuitting = true;
}
-
+
///
- /// Loads all card definitions from the specified folder
+ /// Loads all card definitions from Addressables using the "BlokkemonCard" label
///
- private void LoadCardDefinitionsFromFolder()
+ private async void LoadCardDefinitionsFromAddressables()
{
- // Initialize list if needed
- if (availableCards == null)
+ availableCards = new List();
+ // Load by label instead of group name for better flexibility
+ var handle = UnityEngine.AddressableAssets.Addressables.LoadResourceLocationsAsync(new string[] { "BlokkemonCard" }, UnityEngine.AddressableAssets.Addressables.MergeMode.Union);
+ await handle.Task;
+ if (handle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
{
- availableCards = new List();
- }
-
-#if UNITY_EDITOR
- // In editor we can load assets directly from the project folder
- string folderPath = "Assets/" + cardDataPath;
- string[] guids = AssetDatabase.FindAssets("t:CardDefinition", new[] { folderPath });
-
- List loadedDefinitions = new List();
- foreach (string guid in guids)
- {
- string assetPath = AssetDatabase.GUIDToAssetPath(guid);
- CardDefinition cardDef = AssetDatabase.LoadAssetAtPath(assetPath);
- if (cardDef != null && !string.IsNullOrEmpty(cardDef.Id))
+ var locations = handle.Result;
+ var loadedIds = new HashSet();
+ foreach (var loc in locations)
{
- loadedDefinitions.Add(cardDef);
+ var cardHandle = UnityEngine.AddressableAssets.Addressables.LoadAssetAsync(loc);
+ await cardHandle.Task;
+ if (cardHandle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
+ {
+ var cardDef = cardHandle.Result;
+ if (cardDef != null && !string.IsNullOrEmpty(cardDef.Id) && !loadedIds.Contains(cardDef.Id))
+ {
+ availableCards.Add(cardDef);
+ loadedIds.Add(cardDef.Id);
+ }
+ }
}
}
-
- // Replace the existing list with loaded definitions
- availableCards = loadedDefinitions;
-#else
- // In build, load from Resources folder
- CardDefinition[] resourceCards = Resources.LoadAll(cardDataPath);
- if (resourceCards != null && resourceCards.Length > 0)
- {
- availableCards = resourceCards.Where(card => card != null && !string.IsNullOrEmpty(card.Id)).ToList();
- }
-#endif
-
- Logging.Debug($"[CardSystemManager] Loaded {availableCards.Count} card definitions from {cardDataPath}");
}
///
diff --git a/Assets/Scripts/Minigames/DivingForPictures/Monster/Monster.cs b/Assets/Scripts/Minigames/DivingForPictures/Monster/Monster.cs
index 56949ee7..f342e507 100644
--- a/Assets/Scripts/Minigames/DivingForPictures/Monster/Monster.cs
+++ b/Assets/Scripts/Minigames/DivingForPictures/Monster/Monster.cs
@@ -2,7 +2,6 @@
using Core;
using System;
using System.Collections;
-using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.Audio;
diff --git a/Assets/Scripts/Utils/AppleHillsUtils.cs b/Assets/Scripts/Utils/AppleHillsUtils.cs
index 7a90a65f..306bed2d 100644
--- a/Assets/Scripts/Utils/AppleHillsUtils.cs
+++ b/Assets/Scripts/Utils/AppleHillsUtils.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
using AppleHills.Core.Settings;
using Core;
@@ -72,10 +73,37 @@ namespace Utils
return frameAdjustedSpeed * screenNormalizationFactor;
}
- public static bool AddressableKeyExists(object key)
+ public static bool AddressableKeyExists(object key, Addressables.MergeMode mergeMode = Addressables.MergeMode.Union)
{
- IList locations;
- return Addressables.LoadResourceLocationsAsync(key).WaitForCompletion()?.Count > 0;
+ try
+ {
+ // Handle different key types
+ if (key is string[] keyArray)
+ {
+ // For string arrays, use the array as is with merge mode
+ return Addressables.LoadResourceLocationsAsync(keyArray, mergeMode).WaitForCompletion()?.Count > 0;
+ }
+ else if (key is IEnumerable