为 Unity 的可寻址资产系统自动实现地址指定、标签设置和版本控制。
Smart Addresser is a tool for automating the assigning of addresses and labels in the Unity's Addressable Asset System. You can assign addresses and labels easily using GUI tool. And it also has the version management feature to exclude pre-release assets from the build.
Details
In the Addressable Asset System, you can register addresses by dragging and dropping assets into the Addressables Group Window as shown blow.
However, in reality, it is difficult to manually register all assets. Smart Addresser is a tool to automate this task. For example, you can easily assign addresses by setting up the rules like the following.
You can freely create rules using the GUI tool as follows.
And Smart Addresser also has the version management feature. You can exclude pre-release assets from the build by setting the version number of the asset.
There is also a tool that allows you to check and validate the actual addresses, labels, and versions that are assigned by the rules.
You can also use the CLI to incorporate the addressing and validation process into the CI/CD process.
Or, open Packages/manifest.json and add the following to the dependencies block.
{
"dependencies": {
"jp.co.cyberagent.smartaddresser": "https://github.com/CyberAgentGameEntertainment/SmartAddresser.git?path=/Assets/SmartAddresser"
}
}If you want to set the target version, write as follows.
To update the version, rewrite the version as described above.
If 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.
{
"dependencies": {
"jp.co.cyberagent.smartaddresser": {
"version": "https://github.com/CyberAgentGameEntertainment/SmartAddresser.git?path=/Assets/SmartAddresser",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "..."
}
}
}Note
If you already have set up Addressable Asset System, skip this section.
Before you use Smart Addresser, you need to set up the Addressable Asset System. If not, set up it as follows.
Next you need to create an asset to store the data for Smart Addresser. Create Layout Data Asset from Assets > Create > Smart Addresser > Layout Rule Data.
Rules for addressing are stored in this asset.
You can create multiple assets in the same project. And you can create it in any folder under the Editor folder.
Next, double-click the asset or click the Open Editor button in the Inspector to open the Layout Rule Editor.
In 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.
The Groups column displays a list of Addressable Asset Groups in your project. If you check the checkbox in the Control column, Smart Addresser will control the Addressable Asset Group.
Next, select a item and set up the rules for that Addressable Asset Group in the panel on right.
In the Asset Groups tab you can specify which assets to target. For 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.
See Asset Filter of Asset Group for details on filters other than Object Filter. You can also set multiple filters, and they will be combined with AND. If you want to use OR, click Add Asset Group to add another Asset Group.
In the Address Provider tab, you can specify the address to be assigned to the assets. For 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.
See Address Provider for details on address providers.
Note
If you don't use labels, skip this section.
In the Label Rules tab of the Layout Rule Editor, you can set the rules to assign labels to assets (called Label Rules).
First, click the + button at the top left to add new Label Rule. You can rename it by clicking the item.
Next, select a item and set up the rules for that Label Rule in the right panel.
In the Asset Groups tab you can specify which assets to target. Usage is the same as the Address Rules tab.
In the Label Provider tab you can specify the labels to be assigned to the assets. For example below, set the Label named test.
Now, when you set up addresses, etc. as described above, the following problems may occur.
We provide Layout Viewer as a tool to detect such rule misconfigurations.
You can open it from Window > Smart Addresser > Layout Viewer. When 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.
Use this tool to adjust the layout rules and eliminate warnings and errors.
Now that you have set up the rules, you can apply them to the Addressable Asset System.
From the Layout Rule Editor, you can apply the rules by following the steps below.
It is possible to set whether to treat each of avobe issue as an error or a warning in Project Settings > Smart Addresser > Validation Settings.
You can also apply rules automatically when you import assets or edit the rules. To do this, set the Layout Rule Data which you want to apply to the Primary Data of the Project Settings.
You can also apply rules by CLI. See details in Command Line Interface.
There are cases where the layout rules are corrupted, such as when the object set in the Object Filter is deleted.
You can check for corrupted layout rules by setting Project Settings > Smart Addresser > Layout Rule Corruption.
The items are as follows.
| Item Name | Description |
|---|---|
| Throws Exception | Throw an exception if the layout rule is corrupted. The application process is not performed. |
| Log Error | Output an error log if the layout rule is corrupted. The application process is performed. |
| Ignore | Ignore the corrupted layout rule and apply the process. |
Smart Addresser can provide version to each asset. You can register only specified assets to the Addressable Asset System by specifying the version when you apply the rules.
Expression of versioning follows Semantic Versioning. For example, you can use the following versioning.
Expression of version range follows Version Define expressions. So you can express the version x range as follows.
You can specify the version of each asset in the Version Rules tab of the Layout Rule Editor.
First, click the + button at the top left to add new Version Rule. You can rename it by clicking the item.
Next, select a item and set up the rules for that Version Rule in the right panel.
In the Asset Groups tab you can specify which assets to target. Usage is the same as the Address Rules tab.
In the Version Provider tab you can specify the version to be assigned to the assets. For example below, set the version to 1.2.0.
You can also use the other version providers by clicking the **Ch
暂无开放 Issues,或尚未同步最近议题。