Addressables¶
These are Unity Addressables, that you can assign to your object parameters. If you are not using Addressables in your game, you should ignore this page.
Install Addressables Plugin¶
First of all, you need to install the latest Unity Addressables package.
Next, install the Balancy package:
- In Unity Open Tools ► Balancy ► Updates
- Install the Addressables + CDN Hosting plugin.
In the asmdef file of your game, you need to add the reference to the Balancy.AddressablesNew assembly. This is necessary for the Addressables to work correctly with Balancy.
Synchronize Addressables¶
- In Unity Open Tools ► Balancy ► Config
- Click on Addressables (NEW).
- Follow the instuctions in the window:
- Create Balancy profile by clicking on the button in the first section.
- Provide the Private Key of your game, you can find it in the Balancy dashboard.
- Activate all the Addressables Group you want Balancy to host for you.
- The window should look like this:
- Start Build
- Balancy generates Addressable bundles and stores a local copy in the Library/BalancyData folder.
- Balancy uploads the Addressable bundles to the CDN.
- Balancy generates a JSON file with the list of all Addressables and their URLs, uploading it to Balancy servers.
- What's next
- Go back to Balancy and refresh the page. Open the Assets/Addressables section. You can see the previews for your assets:
- In order to make the bundle public, you have to Deploy the changes.
- Go back to Balancy and refresh the page. Open the Assets/Addressables section. You can see the previews for your assets:
If you have any parameter of type Asset, you'll be able to pick it from the dropdown menu:
How to test¶
You can load the addressable in your game using the following code:
If you have a document with an Asset parameter, you can load it like this:
document.MyAsset.LoadAsset(asset =>
{
});
//if the asset is a type of sprite:
document.MyAsset.LoadSprite(sprite =>
{
});
Alternatively, you can load any asset by its name:
Balancy.AssetsRuntime.GetObject("MyAssetName", asset =>
{
});
//if the asset is a type of sprite:
Balancy.AssetsRuntime.GetSprite("MySpriteName", sprite =>
{
});
While testing in Unity, the local Addressables are used by default. If you want to test the production version, using the CDN: 1. Open Window ► Asset Management ► Addressables ► Groups 2. Select Play Mode Script ► Use Existing Build 3. Make sure you've built the Addressables using Balancy tools before testing.