diff --git a/Documentation~/AddressableImporter.md b/Documentation~/AddressableImporter.md index 9595805..97ff34b 100644 --- a/Documentation~/AddressableImporter.md +++ b/Documentation~/AddressableImporter.md @@ -13,7 +13,7 @@ Table of Contents ## Setup the Importer -You should create a single AddressableImportSettings file located at `Assets/AddressableAssetsData/AddressableImportSettings.asset`. To create it, go to `Assets/AddressableAssetsData` folder, right click in your project window and choose `Create > Addressable Assets > Import Settings`. +You should create a single AddressableImportSettings file located at `Assets/AddressableAssetsData/AddressableImportSettings.asset`. To create it, go to `Assets/AddressableAssetsData` folder, right click in your project window and choose `Create > Addressables > Import Settings`. ![AddressableImportSettings Create](AddressableImportSettings-Create.png) @@ -95,18 +95,18 @@ In another word, if you are intending to manually change the address later, leav You can add a label to your addressable asset. You can choose between: -- `Label Refs`: use a static label already created in Unity project +- `Label Refs`: use a static label already created in Unity project - `Dynamic Labels`: you can automatically create label in your Unity project and add it to your addressable asset. - You can use the same rules to create a dynamic name group explained in [Group Replacement](#group-replacement). - + You can use the same rules to create a dynamic name group explained in [Group Replacement](#group-replacement). + | Asset Path | Rule Path | Label Replacement | Result | |------------------------|-----------------------------------------------|-----------------------------------|------------------| | `Assets/cat/cat01.png` | `Assets/(?[^/]+)/(.*)\.png` | `${category}` | cat | - - + + For an interactive example you can watch this video: https://youtu.be/r5bCKY6TvP0 - - + + The importer always overrides existing labels if `LabelMode = Replace`. ## Quick Assets Re-import @@ -141,5 +141,3 @@ error CS0246: The type or namespace name 'ISearchFilterable' could not be found ``` Notice that the Odin support may be moved to an additional plugin or discontinued if the importer's UX gets improved in the future. - - diff --git a/Editor/AddressableImportSettings.cs b/Editor/AddressableImportSettings.cs index fcf7a9f..a1f20f6 100644 --- a/Editor/AddressableImportSettings.cs +++ b/Editor/AddressableImportSettings.cs @@ -9,10 +9,10 @@ using Sirenix.OdinInspector; #endif -[CreateAssetMenu(fileName = "AddressableImportSettings", menuName = "Addressable Assets/Import Settings", order = 50)] +[CreateAssetMenu(fileName = "AddressableImportSettings", menuName = "Addressables/Import Settings", order = 50)] public class AddressableImportSettings : ScriptableObject { - public const string kDefaultConfigObjectName = "addressableimportsettings"; + public const string kConfigObjectName = "addressableimportsettings"; public const string kDefaultPath = "Assets/AddressableAssetsData/AddressableImportSettings.asset"; [Tooltip("Creates a group if the specified group doesn't exist.")] @@ -63,14 +63,25 @@ public static AddressableImportSettings Instance get { AddressableImportSettings so; - // Try to locate settings via EditorBuildSettings. - if (EditorBuildSettings.TryGetConfigObject(kDefaultConfigObjectName, out so)) + // Try to locate settings from EditorBuildSettings + if (EditorBuildSettings.TryGetConfigObject(kConfigObjectName, out so)) return so; - // Try to locate settings via path. + // Try to locate settings from default path so = AssetDatabase.LoadAssetAtPath(kDefaultPath); - if (so != null) - EditorBuildSettings.AddConfigObject(kDefaultConfigObjectName, so, true); - return so; + if (so != null) { + EditorBuildSettings.AddConfigObject(kConfigObjectName, so, true); + return so; + } + // Try to locate settings from AssetDatabase + var path = AssetDatabase.FindAssets($"t:{nameof(AddressableImportSettings)}"); + if (path.Length > 0) { + var assetPath = AssetDatabase.GUIDToAssetPath(path[0]); + so = AssetDatabase.LoadAssetAtPath(assetPath); + EditorBuildSettings.AddConfigObject(kConfigObjectName, so, true); + return so; + } + return null; } } + } \ No newline at end of file diff --git a/Editor/AddressableImporter.cs b/Editor/AddressableImporter.cs index e04acbd..641c5e6 100644 --- a/Editor/AddressableImporter.cs +++ b/Editor/AddressableImporter.cs @@ -40,7 +40,7 @@ static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAsse var importSettings = AddressableImportSettings.Instance; if (importSettings == null) { - Debug.LogWarningFormat("[AddressableImporter] import settings file not found.\nPlease go to Assets/AddressableAssetsData folder, right click in the project window and choose 'Create > Addressable Assets > Import Settings'."); + Debug.LogWarningFormat("[AddressableImporter] import settings file not found.\nPlease go to Assets/AddressableAssetsData folder, right click in the project window and choose 'Create > Addressables > Import Settings'."); return; } if (importSettings.rules == null || importSettings.rules.Count == 0)