Warning
My company has released a more sophisticated tool called Smart Addresser, so I recommend using it instead. This tool will not be archived, but there are no plans for active improvements.
EZAddresser is automatic addressing system for Unity Addressable Asset System.
You can load assets in very simple two steps:
- Put the asset you want to load into the "Addressables" folder.
- Call
Addressables.LoadAssetAsync("[asset name here]")
.
Unity 2020.1 or higher (because of generic type serialization).
- Open the Package Manager from Window > Package Manager
- "+" button > Add package from git URL
- Enter the following
Or, open Packages/manifest.json and add the following to the dependencies block.
{
"dependencies": {
"com.harumak.ezaddresser": "https://github.com/Haruma-K/EZAddresser.git?path=/Packages/com.harumak.ezaddresser"
}
}
If you want to set the target version, specify it like follow.
This software is released under the MIT License.
You are free to use it within the scope of the license.
However, the following copyright and license notices are required for use.
https://github.com/Haruma-K/EZAddresser/blob/master/LICENSE.md
You can load the assets with EZAddresser by following steps:
- Create a folder named "Addressables".
- Store the assets you want to load in the "Addressables" folder.
- Call Addressables.LoadAssetAsync([file name]) to load them.
In this process, addresses and groups are created according to the following rules.
- Addresses will be created to match the file name without extension. (This can be changed, see below.)
- Multiple "Addressables" folders can be created and folders can be nested together.
- the AssetBundle will be split per "Addressables" folders. (This can be changed, see below.)
You can edit the global settings from Window > EZAddresser > Settings.
The description of each setting item is as follows.
Item Name | Description |
---|---|
Base Packing Mode | Pack By Addressables Folder: AssetBundle is split according to the "Addressables" folder. Pack Together: All assets are stored in the same AssetBundle. |
Base Addressing Mode | Asset Name: File names with extensions are used for addresses. Asset Name Without Extensions: File names without extensions are used for addresses. Addressable Path: Relative paths from the "Addressables" folder with extensions are used for addresses. Addressable Path Without Extensions: Relative paths from the "Addressables" folder without extensions are used for addresses. |
Group Template | Template used to create a group. If not set, the first template set in AddressableAssetSettings will be used. |
When you change these setting items, the following dialog will appear and all addresses and groups will be updated.
Note that when you change the Group Template, all groups will be deleted once and the settings for each group will be reset.
You can edit the per asset settings from Window > EZAddresser > Entry Rule Editor.
You can create a new rule from the Create button on the toolbar.
The description of each setting item is as follows.
Item Name | Description |
---|---|
Addressable Path Rule | Regular expression representing the relative path of the target asset from the Addressables folder. |
Addressing Mode | Addressing Mode to be applied to the target asset. |
Group Name Rule | Group name to which the target asset belongs. The actual group name is retrieved with Regex.Replace([Addressable Path], [Addressable Path Rule], [Group Name Rule]) .However, '/' is replaced by '-' because it is not an appropriate group name. |
Label Rule(s) | The name of the label to attach to the target asset. The actual label is retrieved with Regex.Replace([Addressable Path], [Addressable Path Rule], [Label Rule]) .Multiple labels can be defined by separating them with commas. Spaces are not allowed in label names. |
For example, if you set the Addressable Path Rule as prepub_sample_(?<prefab_id>[0-9]{3}).prefab, then Both prefab_sample_001.prefab and prefab_sample_002.prefab will be subject to this rule. And if you set the Group Name Rule of this rule as Prefab${prefab_id}, the above Prefabs will be stored in the groups Prefab001 and Prefab002 respectively.
If you change any of these settings, the following dialog will appear and all addresses and groups will be updated.
EZAddresser is designed assuming the following workflow.
The first thing to think about is the prototype or early stage of the project. At this time, it's enough to have all the resources built into the app, and you don't need to think about how to divide the AssetBundle. Therefore, you can just throw the resources you want to load into the Addressables folder without thinking about the details. But you may want to decide only the Base Addressing Mode in Settings.
As the project progresses, a resource delivery server will be prepared to download resources. At this point, you will set up Content Packing & Loading for each group using the Addressalbe asset system features. Also, if you want to change the template for a group, it is recommended to do so at this point.
And as the project gets closer to completion, one of the issues that often comes up is the division unit of the AssetBundle.
Most of the time, you will need to split an asset bundle that is too large into appropriate granularity.
At this point, you can use the Entry Rule Editor to store the assets into the appropriate AssetBundle.
Global settings and per-asset settings can be operated programmatically.
The global settings can be operated as follows.
var settingsService = new SettingsService(new SettingsRepository());
settingsService.UpdateSetting(packingMode, addressingMode, groupTemplateGuid);
settingsService.Save();
Per asset settings can be operated as follows.
var entryRulesService = new EntryRulesService(new EntryRulesRepository());
// Get all rules.
var allRules = entryRulesService.GetState();
// Get the first rule.
var firstRule = allRules.First();
// Update the first rule.
entryRulesService.UpdateRule(firstRule.Id, new EntryRuleUpdateCommand(addressablePathRule, addressingMode, groupNameRule));
// Add rule.
entryRulesService.AddRule(new EntryRuleUpdateCommand(addressablePathRule, addressingMode, groupNameRule));
// Remove Rule.
entryRulesService.RemoveRule(firstRule.Id);
// Save changes.
entryRulesService.Save();