{"id":17357668,"url":"https://github.com/CyberAgentGameEntertainment/SmartAddresser","last_synced_at":"2025-02-26T10:33:52.001Z","repository":{"id":151259560,"uuid":"502859487","full_name":"CyberAgentGameEntertainment/SmartAddresser","owner":"CyberAgentGameEntertainment","description":"Automate Addressing, Labeling, and Version Control for Unity's Addressable Asset System.","archived":false,"fork":false,"pushed_at":"2025-01-30T09:36:32.000Z","size":12523,"stargazers_count":448,"open_issues_count":3,"forks_count":29,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-02-24T10:11:20.072Z","etag":null,"topics":["addressables","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyberAgentGameEntertainment.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-13T07:54:43.000Z","updated_at":"2025-02-23T08:03:05.000Z","dependencies_parsed_at":"2023-12-21T08:10:21.423Z","dependency_job_id":"7b24b147-52a3-425f-9059-f13f524b4afb","html_url":"https://github.com/CyberAgentGameEntertainment/SmartAddresser","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FSmartAddresser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FSmartAddresser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FSmartAddresser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FSmartAddresser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyberAgentGameEntertainment","download_url":"https://codeload.github.com/CyberAgentGameEntertainment/SmartAddresser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240835777,"owners_count":19865555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addressables","unity"],"created_at":"2024-10-15T19:01:30.429Z","updated_at":"2025-02-26T10:33:51.961Z","avatar_url":"https://github.com/CyberAgentGameEntertainment.png","language":"C#","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=500 src=\"Documentation/Images/logo_white.png#gh-dark-mode-only\" alt=\"Smart Addresser\"\u003e\n  \u003cimg width=500 src=\"Documentation/Images/logo_color.png#gh-light-mode-only\" alt=\"Smart Addresser\"\u003e\n\u003c/p\u003e\n\n# Smart Addresser: Automate Addressing, Labeling, and Version Control for Addressables\n\n[![license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.md)\n[![license](https://img.shields.io/badge/PR-welcome-green.svg)](https://github.com/CyberAgentGameEntertainment/AssetRegulationManager/pulls)\n[![license](https://img.shields.io/badge/Unity-2020.3-green.svg)](#Requirements)\n\n**Docs** ([English](README.md), [日本語](README_JA.md))\n\nSmart Addresser is a tool for automating the assigning of addresses and labels in the Unity's Addressable Asset System.\nYou can assign addresses and labels easily using GUI tool.\nAnd it also has the version management feature to exclude pre-release assets from the build.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/smart_addresser_en.gif\" alt=\"ConceptMovie\"\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\u003cdetails\u003e\n\u003csummary\u003eDetails\u003c/summary\u003e\n\n- [Concept](#concept)\n- [Setup](#setup)\n  - [Requirement](#requirement)\n  - [Install](#install)\n- [Set up rules to assign addresses](#set-up-rules-to-assign-addresses)\n  - [Set up Addressable Asset System](#set-up-addressable-asset-system)\n  - [Create an asset to store the data](#create-an-asset-to-store-the-data)\n  - [Create Address Rules](#create-address-rules)\n  - [Create Label Rules](#create-label-rules)\n- [Validation](#validation)\n- [Apply to Addressable Asset System](#apply-to-addressable-asset-system)\n  - [Apply from Layout Rule Editor](#apply-from-layout-rule-editor)\n  - [Apply rules automatically](#apply-rules-automatically)\n  - [Apply by CLI](#apply-by-cli)\n  - [Detecting corrupted layout rules](#detecting-corrupted-layout-rules)\n- [Version Management](#version-management)\n  - [Versioning Specification](#versioning-specification)\n  - [Create Version Rules](#create-version-rules)\n  - [Apply with specified version range](#apply-with-specified-version-range)\n  - [About versioning and asset dependencies](#about-versioning-and-asset-dependencies)\n  - [Use your own version range expression](#use-your-own-version-range-expression)\n- [Command Line Interface (CLI)](#command-line-interface-cli)\n  - [Set Version Expression](#set-version-expression)\n  - [Detecting corrupted layout rules](#detecting-corrupted-layout-rules-1)\n  - [Apply Layout Rules to Addressable Asset System](#apply-layout-rules-to-addressable-asset-system)\n- [Scripting](#scripting)\n  - [Edit Layout Rule Data](#edit-layout-rule-data)\n  - [Validation and Apply to Addressable Asset System](#validation-and-apply-to-addressable-asset-system)\n- [List and descriptions of Asset Filter and Providers](#list-and-descriptions-of-asset-filter-and-providers)\n  - [Asset Filter of Asset Group](#asset-filter-of-asset-group)\n  - [Address Provider](#address-provider)\n  - [Label Provider](#label-provider)\n  - [Version Provider](#version-provider)\n- [Create your own Asset Filters / Providers](#create-your-own-asset-filters--providers)\n  - [Create your own Asset Filter](#create-your-own-asset-filter)\n  - [Create your own Provider](#create-your-own-provider)\n- [License](#license)\n\n\u003c/details\u003e\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\n## Concept\nIn the Addressable Asset System, you can register addresses by dragging and dropping assets into the **Addressables Group Window** as shown blow.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/concept_01.gif\" alt=\"Concept\"\u003e\n\u003c/p\u003e\n\nHowever, in reality, it is difficult to manually register all assets.\nSmart Addresser is a tool to automate this task.\nFor example, you can easily assign addresses by setting up the rules like the following.\n\n* Assign addresses to all Prefabs in the specified folder.\n* Assign addresses to all assets in the folder named \"Addressables\".\n* Assign addresses to all assets with a path matching the specified regular expression.\n\nYou can freely create rules using the GUI tool as follows.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/concept_02.png\" alt=\"GUI Tool\"\u003e\n\u003c/p\u003e\n\nAnd Smart Addresser also has the version management feature.\nYou can exclude pre-release assets from the build by setting the version number of the asset.\n\nThere is also a tool that allows you to check and validate the actual addresses, labels, and versions that are assigned by the rules.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/concept_03.png\" alt=\"Layout Viewer\"\u003e\n\u003c/p\u003e\n\nYou can also use the **CLI** to incorporate the addressing and validation process into the CI/CD process.\n\n## Setup\n\n### Requirement\n* Unity 2020.3 or higher.\n* Addressables is installed.\n\n### Install\n1. Open the Package Manager from Window \u003e Package Manager\n2. \"+\" button \u003e Add package from git URL\n3. Enter the following\n    * https://github.com/CyberAgentGameEntertainment/SmartAddresser.git?path=/Assets/SmartAddresser\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_01.png\" alt=\"Package Manager\"\u003e\n\u003c/p\u003e\n\nOr, open Packages/manifest.json and add the following to the dependencies block.\n\n```json\n{\n    \"dependencies\": {\n      \"jp.co.cyberagent.smartaddresser\": \"https://github.com/CyberAgentGameEntertainment/SmartAddresser.git?path=/Assets/SmartAddresser\"\n    }\n}\n```\n\nIf you want to set the target version, write as follows.\n\n* https://github.com/CyberAgentGameEntertainment/SmartAddresser.git?path=/Assets/SmartAddresser#1.0.0\n\nTo update the version, rewrite the version as described above.  \nIf you don't want to specify a version, you can also update the version by editing the hash of this library in the package-lock.json file.\n\n```json\n{\n  \"dependencies\": {\n      \"jp.co.cyberagent.smartaddresser\": {\n      \"version\": \"https://github.com/CyberAgentGameEntertainment/SmartAddresser.git?path=/Assets/SmartAddresser\",\n      \"depth\": 0,\n      \"source\": \"git\",\n      \"dependencies\": {},\n      \"hash\": \"...\"\n    }\n  }\n}\n```\n\n## Set up rules to assign addresses\n\n### Set up Addressable Asset System\n\n\u003e **Note**  \n\u003e If you already have set up Addressable Asset System, skip this section.\n\nBefore you use **Smart Addresser**, you need to set up the Addressable Asset System.\nIf not, set up it as follows.\n\n* Open **Window \u003e Asset Management \u003e Addressables \u003e Groups**.\n* If you see a message that **Addressable** has not been initialized, follow the instructions to initialize it.\n* If necessary, create a new **Addressable Asset Group** to be controlled by **Smart Addresser** from **Create \u003e Groups**.\n\n### Create an asset to store the data\nNext you need to create an asset to store the data for **Smart Addresser**.\nCreate **Layout Data Asset** from **Assets \u003e Create \u003e Smart Addresser \u003e Layout Rule Data**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_01.png\" alt=\"Create Layout Rule Data\"\u003e\n\u003c/p\u003e\n\nRules for addressing are stored in this asset.\n\nYou can create multiple assets in the same project.\nAnd you can create it in any folder under the **Editor** folder.\n\nNext, double-click the asset or click the **Open Editor** button in the Inspector to open the **Layout Rule Editor**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_02.png\" alt=\"Layout Rule Editor\"\u003e\n\u003c/p\u003e\n\n### Create Address Rules\nIn the **Address Rules** tab of the **Layout Rule Editor**, you can set the assets and their addresses to be registered in each **Addressable Asset Group** (called **Address Rule**) in the project.\n\nThe **Groups** column displays a list of **Addressable Asset Groups** in your project.\nIf you check the checkbox in the **Control** column, **Smart Addresser** will control the **Addressable Asset Group**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_03.png\" alt=\"Address Rules Editor\"\u003e\n\u003c/p\u003e\n\nNext, select a item and set up the rules for that **Addressable Asset Group** in the panel on right.\n\nIn the **Asset Groups** tab you can specify which assets to target.\nFor example, to target \"all assets in the folder named Characters\", click the **+** button and select the **Object Filter**, and set the **Characters** folder to the **Object** property, as shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_04.png\" alt=\"Asset Groups\"\u003e\n\u003c/p\u003e\n\nSee [Asset Filter of Asset Group](#asset-filter-of-asset-group) for details on filters other than **Object Filter**.\nYou can also set multiple filters, and they will be combined with **AND**.\nIf you want to use **OR**, click **Add Asset Group** to add another **Asset Group**.\n\nIn the **Address Provider** tab, you can specify the address to be assigned to the assets.\nFor example, if you want to assign the file name without extension as the address, set **File Name Without Extensions** to the **Source** as shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_05.png\" alt=\"Address Provider\"\u003e\n\u003c/p\u003e\n\nSee [Address Provider](#address-provider) for details on address providers.\n\n### Create Label Rules\n\n\u003e **Note**  \n\u003e If you don't use labels, skip this section.\n\nIn the **Label Rules** tab of the **Layout Rule Editor**, you can set the rules to assign labels to assets (called **Label Rules**).\n\nFirst, click the **+** button at the top left to add new **Label Rule**.\nYou can rename it by clicking the item.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_06.png\" alt=\"Label Rules Editor\"\u003e\n\u003c/p\u003e\n\nNext, select a item and set up the rules for that **Label Rule** in the right panel.\n\nIn the **Asset Groups** tab you can specify which assets to target.\nUsage is the same as the **Address Rules** tab.\n\nIn the **Label Provider** tab you can specify the labels to be assigned to the assets.\nFor example below, set the **Label** named **test**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/setup_rules_07.png\" alt=\"Label Provider\"\u003e\n\u003c/p\u003e\n\n## Validation\n\nNow, when you set up addresses, etc. as described above, the following problems may occur.\n\n* Multiple addresses are specified for a single asset.\n* Multiple assets are specified for a single address.\n* Multiple [Versions](#version-management) are specified for a single address.\n\nWe provide **Layout Viewer** as a tool to detect such rule misconfigurations.\n\nYou can open it from **Window \u003e Smart Addresser \u003e Layout Viewer**.\nWhen the **Layout Viewer** is opened, validation is performed and the list of the **Addressable Group**, the list of addresses and the validation results are displayed.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/validation_01.png\" alt=\"Validation\"\u003e\n\u003c/p\u003e\n\nUse this tool to adjust the layout rules and eliminate warnings and errors.\n\n## Apply to Addressable Asset System\n\nNow that you have set up the rules, you can apply them to the Addressable Asset System.\n\n### Apply from Layout Rule Editor\n\nFrom the **Layout Rule Editor**, you can apply the rules by following the steps below.\n\n1. Click the menu button on the top right.\n2. Select **Apply to Addressables**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/apply_01.png\" alt=\"Apply by Editor\"\u003e\n\u003c/p\u003e\n\nIt is possible to set whether to treat each of avobe issue as an error or a warning in **Project Settings \u003e Smart Addresser \u003e Validation Settings**.\n\n### Apply rules automatically\nYou can also apply rules automatically when you import assets or edit the rules.\nTo do this, set the **Layout Rule Data** which you want to apply to the **Primary Data** of the **Project Settings**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/apply_02.png\" alt=\"Apply Automatically\"\u003e\n\u003c/p\u003e\n\n### Apply by CLI\n\nYou can also apply rules by CLI.\nSee details in [Command Line Interface](#command-line-interface--cli-).\n\n### Detecting corrupted layout rules\n\nThere are cases where the layout rules are corrupted, such as when the object set in the Object Filter is deleted.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/apply_03.png\" alt=\"Corrupted Rule\"\u003e\n\u003c/p\u003e\n\nYou can check for corrupted layout rules by setting **Project Settings \u003e Smart Addresser \u003e Layout Rule Corruption**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/apply_04.png\" alt=\"Layout Rule Corruption\"\u003e\n\u003c/p\u003e\n\nThe items are as follows.\n\n| Item Name        | Description                                                                 |\n|------------------|-----------------------------------------------------------------------------|\n| Throws Exception | Throw an exception if the layout rule is corrupted. The application process is not performed. |\n| Log Error        | Output an error log if the layout rule is corrupted. The application process is performed. |\n| Ignore           | Ignore the corrupted layout rule and apply the process.                     |\n\n## Version Management\n\n**Smart Addresser** can provide version to each asset.\nYou can register only specified assets to the Addressable Asset System by specifying the version when you apply the rules.\n\n### Versioning Specification\n\nExpression of versioning follows [Semantic Versioning](https://semver.org/).\nFor example, you can use the following versioning.\n\n* 1.2.3\n* 2.1.0-preview.7\n\nExpression of version range follows [Version Define expressions](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html#version-define-expressions).\nSo you can express the version x range as follows.\n\n* [1.3,3.4.1] means 1.3.0 \u003c= x \u003c= 3.4.1\n* (1.3.0,3.4) means 1.3.0 \u003c x \u003c 3.4.0\n* [1.1,3.4) means 1.1.0 \u003c= x \u003c 3.4.0\n* (0.2.4,5.6.2-preview.2] means 0.2.4 \u003c x \u003c= 5.6.2-preview.2\n* [2.4.5] means x = 2.4.5\n* 2.1.0-preview.7 means x \u003e= 2.1.0-preview.7\n* You cannot use space.\n* Wildcard is not supported.\n\n### Create Version Rules\n\nYou can specify the version of each asset in the **Version Rules** tab of the **Layout Rule Editor**.\n\nFirst, click the **+** button at the top left to add new **Version Rule**.\nYou can rename it by clicking the item.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/versioning_01.png\" alt=\"Set Versions\"\u003e\n\u003c/p\u003e\n\nNext, select a item and set up the rules for that **Version Rule** in the right panel.\n\nIn the **Asset Groups** tab you can specify which assets to target.\nUsage is the same as the **Address Rules** tab.\n\nIn the **Version Provider** tab you can specify the version to be assigned to the assets.\nFor example below, set the version to **1.2.0**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/versioning_02.png\" alt=\"Version Provider\"\u003e\n\u003c/p\u003e\n\nYou can also use the other version providers by clicking the **Change Provider** button.\nSee [Version Provider](#version-provider) for details on version providers.\n\n### Apply with specified version range\n\nTo specify the version range, set the **Version Expression** in the **Settings** tab of the **Layout Rule Editor**.\nIf you check **Exclude Unversioned**, assets without version will be excluded.\nFollowing is an example that targets the assets with version greater than or equal to 1.2.0 and less than 3.4.0 and unversioned assets.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/versioning_03.png\" alt=\"Version Expression\"\u003e\n\u003c/p\u003e\n\nNow, when you apply the rules, only assets with specified versions will be registered to the Addressable Asset System.\n\n### About versioning and asset dependencies\n\nThe version management feature of **Smart Addresser** is designed to exclude pre-released assets from the build.\nFor example, if you specify the version range as **[1.0.0,1.2.0]** assets with version greater than 1.2.0 will be excluded from the build.\n\nWhen using this, you need to be careful not to reference a higher version asset from a lower version asset.\nSuch dependencies will cause unintended asset updates.\nFor example, a version **1.2.0** of asset A references a version **1.3.0** of asset B.\nIf you build **1.2.0** and then build **1.3.0**, not only asset B but also asset A will be updated.\n\nNormally, such as dependencies are not constructed, but beware.\n\n### Use your own version range expression\nAs noted above, the version range expression follows [Version Define expressions](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html#version-define-expressions).\n\nIf you want to use your own version range expression, you can implement the `IVersionExpressionParser` interface and set the script to the **Project Settings \u003e Smart Addresser \u003e Version Expression Parser**.\n\n## Command Line Interface (CLI)\n\n### Set Version Expression\n\nYou can set the version expression by calling the following method.\n\n`SmartAddresser.Editor.Core.Tools.CLI.SmartAddresserCLI.SetVersionExpression`\n\nThe following is an example of how to set the version expression from the command line in Mac.\n\n```\n/Applications/Unity/Hub/Editor/2020.3.40f1/Unity.app/Contents/MacOS/Unity -projectPath [Your Project Path Here] -executeMethod SmartAddresser.Editor.Core.Tools.CLI.SmartAddresserCLI.SetVersionExpression\n```\n\nCommand line arguments are as follows.\n\n\n| Argument Name                            | Description                                                                                     |\n|------------------------------------------|-------------------------------------------------------------------------------------------------|\n| -layoutRuleAssetPath \\\u003cassetPath\\\u003e       | Asset Path of the Layout Rule Data to be applied.\u003cbr\u003eIf not specified, use the first one found. |\n| -versionExpression \\\u003cversionExpression\\\u003e | Version Expression.                                                                             |\n\nWhen completed, Unity is automatically closed and returns the following value.\n\n- If successful: 0\n- If failed: 1\n\n### Detecting corrupted layout rules\n\nYou can use the `SmartAddresser.Editor.Core.Tools.CLI.SmartAddresserCLI.ValidateLayoutRules` method to check for corrupted layout rules from the command line.\n\nThe following is an example of how to check for corrupted layout rules from the command line in Mac.\n\n```\n/Applications/Unity/Hub/Editor/2020.3.40f1/Unity.app/Contents/MacOS/Unity -projectPath [Your Project Path Here] -executeMethod SmartAddresser.Editor.Core.Tools.CLI.SmartAddresserCLI.ValidateLayoutRules\n```\n\nCommand line arguments are as follows.\n\n| Argument Name                            | Description                                                                                     |\n|------------------------------------------|-------------------------------------------------------------------------------------------------|\n| -layoutRuleAssetPath \\\u003cassetPath\\\u003e       | Asset Path of the Layout Rule Data to be applied.\u003cbr\u003eIf not specified, use the first one found. |\n| -errorLogFilePath \\\u003cfilePath\\\u003e     | Output file path for validation result.\u003cbr\u003eDefault is Logs/SmartAddresser_LayoutRuleError.json. |\n\nWhen completed, Unity is automatically closed and returns the following value.\n\n- If successful: 0\n- If the layout rule is corrupted: 1\n- If an error occurred during execution: 2\n\n### Apply Layout Rules to Addressable Asset System\n\nYou can apply the layout rules to the Addressable Asset System by calling the following method.\n\n`SmartAddresser.Editor.Core.Tools.CLI.SmartAddresserCLI.ApplyRules`\n\nThe following is an example of how to apply the layout rules from the command line in Mac.\n\n```\n/Applications/Unity/Hub/Editor/2020.3.40f1/Unity.app/Contents/MacOS/Unity -quit -batchmode -projectPath /Users/s14774/Unity/SmartAddresser_Sample -executeMethod SmartAddresser.Editor.Core.Tools.CLI.SmartAddresserCLI.ApplyRules\n```\n\nCommand line arguments are as follows.\n\n| Argument Name                     | Description                                                                                                                             |\n|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|\n| -layoutRuleAssetPath \\\u003cassetPath\\\u003e | Asset Path of the Layout Rule Data to be applied.\u003cbr\u003eIf not specified, use the first one found.                                         |\n| -validateLayoutRule               | If enabled, check for corrupted layout rules before applying.                                                                           |\n| -validateLayout                   | If enabled, validation will be executed before applying.\u003cbr\u003eThe validation is a time-consuming process so can be skipped if not needed. |\n| -resultFilePath \\\u003cfilePath\\\u003e      | Output file path for validation result.\u003cbr\u003eDefault is SmartAddresser/validate_result.json.                                              |\n| -failWhenWarning                  | If enabled, any warning in the validation is considered an execution error.                                                             |\n\nWhen completed, Unity is automatically closed and returns the following value.\n\n- If successful: 0\n- If validation failed: 1\n- If execution failed: 2\n\n## Scripting\n\n**Smart Addresser** can also be operated from scripts.\n\n### Edit Layout Rule Data\n\nThe following is an example of how to edit the layout rule data from scripts.\n\n```cs\nusing System.Linq;\nusing SmartAddresser.Editor.Core.Models.LayoutRules;\nusing SmartAddresser.Editor.Core.Models.LayoutRules.AddressRules;\nusing SmartAddresser.Editor.Core.Models.LayoutRules.LabelRules;\nusing SmartAddresser.Editor.Core.Models.LayoutRules.VersionRules;\nusing SmartAddresser.Editor.Core.Models.Shared;\nusing SmartAddresser.Editor.Core.Models.Shared.AssetGroups.AssetFilterImpl;\nusing UnityEditor;\nusing UnityEditor.AddressableAssets.Settings;\n\npublic static class Example\n{\n    private const string LayoutRuleDataAssetPath = \"Assets/LayoutRuleData.asset\";\n    private const string AddressableAssetGroupAssetPath = \"Assets/AddressableAssetsData/AssetGroups/ExampleGroup.asset\";\n\n    [MenuItem(\"Tools/Smart Addresser/Example/Setup Layout Rule Data\")]\n    public static void SetupLayoutRuleDataProgramatically()\n    {\n        // Load LayoutRuleData\n        var data = AssetDatabase.LoadAssetAtPath\u003cLayoutRuleData\u003e(LayoutRuleDataAssetPath);\n\n        // Remove \u0026 Add AddressRule\n        var group = AssetDatabase.LoadAssetAtPath\u003cAddressableAssetGroup\u003e(AddressableAssetGroupAssetPath);\n        var addressRule = data.LayoutRule.AddressRules.FirstOrDefault(x =\u003e x.AddressableGroup == group);\n        if (addressRule != null)\n            data.LayoutRule.AddressRules.Remove(addressRule);\n        addressRule = CreateAddressRule(group);\n        data.LayoutRule.AddressRules.Add(addressRule);\n\n        // Add LabelRule\n        data.LayoutRule.LabelRules.Add(CreateLabelRule());\n\n        // Add VersionRule\n        data.LayoutRule.VersionRules.Add(CreateVersionRule());\n\n        EditorUtility.SetDirty(data);\n        AssetDatabase.SaveAssets();\n    }\n\n    private static AddressRule CreateAddressRule(AddressableAssetGroup group)\n    {\n        // Create new AddressRule.\n        var addressRule = new AddressRule(group);\n\n        // Set the Control property true to activate this rule.\n        addressRule.Control.Value = true;\n\n        // Set the target assets of this rule.\n        // In this case, all png files are targeted.\n        var assetGroup = addressRule.AssetGroups[0];\n        var assetFilter = new ExtensionBasedAssetFilter();\n        assetFilter.Extension.Value = \"png\";\n        assetGroup.Filters.Add(assetFilter);\n\n        // Set the address pattern of this rule.\n        // In this case, set the asset name as the address.\n        var addressProvider = new AssetPathBasedAddressProvider();\n        addressProvider.Source = PartialAssetPathType.FileName;\n        addressRule.AddressProvider.Value = addressProvider;\n\n        return addressRule;\n    }\n\n    private static LabelRule CreateLabelRule()\n    {\n        var labelRule = new LabelRule();\n        labelRule.Name.Value = \"NormalMap\";\n\n        // Set the target assets of this rule.\n        // In this case, all files that contains \"_Normal\" in the name are targeted.\n        var assetGroup = labelRule.AssetGroups[0];\n        var assetFilter = new RegexBasedAssetFilter();\n        assetFilter.AssetPathRegex.Value = \"_Normal\";\n        assetGroup.Filters.Add(assetFilter);\n\n        // Set the label provider.\n        // In this case, set the label \"NormalMap\".\n        var labelProvider = new ConstantLabelProvider();\n        labelProvider.Label = \"NormalMap\";\n        labelRule.LabelProvider.Value = labelProvider;\n\n        return labelRule;\n    }\n\n    private static VersionRule CreateVersionRule()\n    {\n        var versionRule = new VersionRule();\n        versionRule.Name.Value = \"1.0.0\";\n\n        // Set the target assets of this rule.\n        // In this case, all files that contains \"Ellen\" in the name are targeted.\n        var assetGroup = versionRule.AssetGroups[0];\n        var assetFilter = new RegexBasedAssetFilter();\n        assetFilter.AssetPathRegex.Value = \"Ellen\";\n        assetGroup.Filters.Add(assetFilter);\n\n        // Set the version provider.\n        // In this case, set the version \"1.0.0\".\n        var versionProvider = new ConstantVersionProvider();\n        versionProvider.Version = \"1.0.0\";\n        versionRule.VersionProvider.Value = versionProvider;\n\n        return versionRule;\n    }\n}\n```\n\n### Validation and Apply to Addressable Asset System\n\nThe following is an example of how to validate and apply the layout rules to the Addressable Asset System from scripts.\n\n```cs\nusing System;\nusing System.Linq;\nusing SmartAddresser.Editor.Core.Models.LayoutRules;\nusing SmartAddresser.Editor.Core.Models.Layouts;\nusing SmartAddresser.Editor.Core.Models.Services;\nusing SmartAddresser.Editor.Core.Tools.Shared;\nusing SmartAddresser.Editor.Foundation.AddressableAdapter;\nusing SmartAddresser.Editor.Foundation.AssetDatabaseAdapter;\nusing UnityEditor;\nusing UnityEditor.AddressableAssets;\n\npublic static class Example\n{\n    private static void Apply()\n    {\n        var layoutRuleData = LoadLayoutRuleData();\n        var layoutRule = layoutRuleData.LayoutRule;\n        var versionExpressionParser = new VersionExpressionParserRepository().Load();\n        var assetDatabaseAdapter = new AssetDatabaseAdapter();\n        var addressableSettings = AddressableAssetSettingsDefaultObject.Settings;\n        var addressableSettingsAdapter = new AddressableAssetSettingsAdapter(addressableSettings);\n\n        // Set Version Expression\n        {\n            // Set the version expression.\n            layoutRule.Settings.VersionExpression.Value = \"1.3.0\";\n\n            // Save the LayoutRuleData asset.\n            EditorUtility.SetDirty(layoutRuleData);\n            AssetDatabase.SaveAssets();\n        }\n\n        // Validation\n        {\n            // Build and validate the Layout.\n            var buildLayoutService = new BuildLayoutService(assetDatabaseAdapter);\n            var layout = buildLayoutService.Execute(layoutRule);\n            layout.Validate(true);\n\n            // Export the result of the validation.\n            var validateResultExportService = new ValidateResultExportService(layout);\n            validateResultExportService.Run(\"Smart Addresser/validate-result.json\");\n\n            // Throw exception if the validation failed.\n            if (layout.ErrorType == LayoutErrorType.Error || layout.ErrorType == LayoutErrorType.Warning)\n                throw new Exception($\"Validation failed: {layout.ErrorType}\");\n        }\n\n        // Apply\n        {\n            // Apply the layout rules to the addressable asset system.\n            var applyService = new ApplyLayoutRuleService(layoutRule, versionExpressionParser,\n                addressableSettingsAdapter, assetDatabaseAdapter);\n            applyService.ApplyAll();\n        }\n    }\n\n    private static LayoutRuleData LoadLayoutRuleData(string assetPath = null)\n    {\n        if (!string.IsNullOrEmpty(assetPath))\n            return AssetDatabase.LoadAssetAtPath\u003cLayoutRuleData\u003e(assetPath);\n\n        var guid = AssetDatabase.FindAssets($\"t: {nameof(LayoutRuleData)}\").FirstOrDefault();\n        if (string.IsNullOrEmpty(guid))\n            throw new InvalidOperationException(\"There is no LayoutRuleData in the project.\");\n\n        assetPath = AssetDatabase.GUIDToAssetPath(guid);\n        return AssetDatabase.LoadAssetAtPath\u003cLayoutRuleData\u003e(assetPath);\n    }\n}\n```\n\n## List and descriptions of Asset Filter and Providers\n\n### Asset Filter of Asset Group\n\n| Name                    | Overview and Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Object Filter | Filters by specifying the asset directly.\u003cbr\u003eUse case: Target only assets under the Characters folder.\u003cbr\u003e\u003cbr\u003e**Folder Targeting Mode**\u003cbr\u003eSpecify how folders are handled.\u003cbr\u003e* Included Assets (Exclude Folders): Targets only assets in the folders.\u003cbr\u003e* Self: Targets only the folders themselves.\u003cbr\u003e* Both: Targets the folders and the included assets.\u003cbr\u003e\u003cbr\u003e**Object**\u003cbr\u003eTarget asset. If you specify a folder, target all assets in the folder. Multiple items can be specified by using the right toggle.                                                                                                                                                                                                                                                                 |\n| Type Filter | Filters by asset type.\u003cbr\u003eUse case: Targets only Texture2d type assets.\u003cbr\u003e\u003cbr\u003e**Match With Derived Type**\u003cbr\u003eIf checked, derived types are also covered.\u003cbr\u003e\u003cbr\u003e**Type**\u003cbr\u003eTarget type. Multiple items can be specified by using the right toggle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |\n| Asset Path Filter | Filters by asset path.\u003cbr\u003eUse case 1: Target assets contained in the folder named \"Assets/Sample[Any 3 characters]/\".\u003cbr\u003eUse case 2: Exclude assets that contain \"Dummy\" in the file name.\u003cbr\u003e\u003cbr\u003e**Match With Folders**\u003cbr\u003eTargets the folders or not.\u003cbr\u003e\u003cbr\u003e**Asset Path (Regex)**\u003cbr\u003eTarget asset path. Assets whose paths partially match these will be targeted. You can also use regular expressions. Multiple items can be specified by using the right toggle.\u003cbr\u003e\u003cbr\u003e**Condition**\u003cbr\u003eSpecify how to handle multiple Asset Paths.\u003cbr\u003e* Contains Matched: Target if any asset path matches.\u003cbr\u003e* Match All: Target if all asset paths match.\u003cbr\u003e* Contains Unmatched: Target if any one asset path does not match.\u003cbr\u003e* Not Match All: Target if all asset paths do not match. |\n| Extension Filter | Filters by extension.\u003cbr\u003eUse case: Target assets that have png or jpg extension.\u003cbr\u003e\u003cbr\u003e**Extension**\u003cbr\u003eTarget extension. Multiple items can be specified by using the right toggle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |\n| Dependent Object Filter | Filters the assets that are referenced by the specified asset.\u003cbr\u003eUse case: Targets the textures that are referenced by the prefab.\u003cbr\u003e\u003cbr\u003e**Only Direct Dependencies**\u003cbr\u003eTargets the assets that are referenced directly.\u003cbr\u003e\u003cbr\u003e**Object**\u003cbr\u003eReferer Assets.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |\n| Find Assets Filter      | Filters by using AssetDatabase.FindAssets().\u003cbr/\u003e\u003cbr/\u003e**Filter**\u003cbr\u003eFilter string to be passed to AssetDatabase.Find()\u003cbr\u003e\u003cbr\u003e**Target Folders**\u003cbr\u003eThe folder to be searched.\u003cbr\u003eIf not specified, all folders will be searched.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n\n### Address Provider\n\n| Name                              | Overview and Property Description                                                                                                                                                                                                                                       |\n|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Asset Path Based Address Provider | Provides an address based on the asset path of the target asset.\u003cbr\u003e\u003cbr\u003e**Source**\u003cbr\u003eHow to specify the address.\u003cbr\u003e* File Name\u003cbr\u003e* File Name Without Extensions\u003cbr\u003e* Asset Path\u003cbr\u003e\u003cbr\u003e**Replace With Regex**\u003cbr\u003eIf checked, the Source will be replaced with regex. |\n\n### Label Provider\n\n| Name                            | Overview and Property Description                                                                                                                                                                                                                                                        |\n|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Constant Label Provider         | Provides an constant label.\u003cbr\u003e\u003cbr\u003eLabel\u003cbr\u003eLabel name.                                                                                                                                                                                                             |\n| Asset Path Based Label Provider | Provides an label based on the asset path of the target asset.\u003cbr\u003e\u003cbr\u003e**Source**\u003cbr\u003eHow to specify the label.\u003cbr\u003e* File Name\u003cbr\u003e* File Name Without Extensions\u003cbr\u003e* Asset Path\u003cbr\u003e\u003cbr\u003e**Replace With Regex**\u003cbr\u003eIf checked, the Source will be replaced with regex. |\n\n### Version Provider\n\n| Name                              | Overview and Property Description                                                                                                                                                                                                                                                            |\n|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Constant Version Provider         | Provides an constant version.\u003cbr\u003e\u003cbr\u003eVersion\u003cbr\u003eversion name.                                                                                                                                                                                                           |\n| Asset Path Based Version Provider | Provides an version based on the asset path of the target asset.\u003cbr\u003e\u003cbr\u003e**Source**\u003cbr\u003eHow to specify the version.\u003cbr\u003e* File Name\u003cbr\u003e* File Name Without Extensions\u003cbr\u003e* Asset Path\u003cbr\u003e\u003cbr\u003e**Replace With Regex**\u003cbr\u003eIf checked, the Source will be replaced with regex. |\n\n## Create your own Asset Filters / Providers\n\n### Create your own Asset Filter\n\nYou can create your own Asset Filter by inheriting the `AssetFilterAsset` class.\n\n```cs\nusing System;\nusing SmartAddresser.Editor.Core.Models.Shared.AssetGroups.AssetFilterImpl;\n\npublic sealed class ExampleAssetFilter : AssetFilterAsset\n{\n    public override void SetupForMatching()\n    {\n        // This method will be called before IsMatch\n        // This method will be called only once, while IsMatch will be called for each asset\n        // Therefore, heavy processing should be done here\n    }\n\n    public override bool IsMatch(string assetPath, Type assetType, bool isFolder)\n    {\n        // Return true if the asset matches this filter\n    }\n\n    public override string GetDescription()\n    {\n        // Return the state of this filter as a string (for editor)\n    }\n}\n```\n\nNext, create a **ScriptableObject** asset of this class (**AssetFilterAsset** inherits **ScriptableObject**).\n\nFinally, add **Example Asset Filter** to the **Asset Group** of **Layout Rule Editor**, and assign the **ScriptableObject** you created to the **Asset Filter** property.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/custom_filter_provider_01.png\" alt=\"Custom Asset Filter\"\u003e\n\u003c/p\u003e\n\n### Create your own Provider\nYou can create your own Provider by inheriting the `AddressProviderAsset` / `LabelProviderAsset` / `VersionProviderAsset` class.\n\n```cs\nusing System;\nusing SmartAddresser.Editor.Core.Models.LayoutRules.AddressRules;\nusing UnityEngine;\n\npublic sealed class ExampleAddressProvider : AddressProviderAsset\n{\n    public override void Setup()\n    {\n        // This method will be called before Provide\n        // This method will be called only once, while Provide will be called for each asset\n        // Therefore, heavy processing should be done here\n    }\n\n    public override string Provide(string assetPath, Type assetType, bool isFolder)\n    {\n        // Return the address corresponding to the asset given as an argument\n        // If there is no corresponding address, return null\n    }\n\n    public override string GetDescription()\n    {\n        // Return the state of this filter as a string (for editor)\n    }\n}\n```\n\nNext, create a **ScriptableObject** asset of this class (**ProviderAsset** inherits **ScriptableObject**).\n\nFinally, press the **Change Provider** button of each **Provider** in **Layout Rule Editor**, select **Custom Provider**, and assign the **ScriptableObject** you created to the **Address Provider** property.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\" src=\"Documentation/Images/custom_filter_provider_02.png\" alt=\"Custom Provider\"\u003e\n\u003c/p\u003e\n\n## License\nThis software is released under the MIT license.\nYou are free to use it within the scope of the license, but the following copyright and license notices are required.\n\n* [LICENSE.md](LICENSE.md)\n\nIn addition, the table of contents for this document has been created using the following software.\n\n* [toc-generator](https://github.com/technote-space/toc-generator)\n\nSee [Third Party Notices.md](Third%20Party%20Notices.md) for more information about the license of toc-generator.\n","funding_links":[],"categories":["Unity","Open Source Repositories"],"sub_categories":["Lua","Asset Bundle / Addressable Assets"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCyberAgentGameEntertainment%2FSmartAddresser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCyberAgentGameEntertainment%2FSmartAddresser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCyberAgentGameEntertainment%2FSmartAddresser/lists"}