- Home /
How to convert Resources.LoadAll to Addressables?
I have been advised to move away from the Resources system to the new Addressables system, which seems to have many advantages.
I need to convert the following code to use the Addressables:
public static void LoadDefs()
{
foreach (var baseTileType in Resources.LoadAll(Settings.BASE_TILES_PATH, typeof(TextAsset)))
{
var baseTile = Deserializer.Deserialize<BaseTile.Initializer>(((TextAsset) baseTileType).text);
BaseTileInstances.Add(baseTile.Name, baseTile.CreateInstance());
}
}
I need to detect the type of TextAsset because those are .yaml files that I need to load the information from. Then, derived from information in that YAML file, I load sprites that I need with Resources.Load(path) later, but that should be simple.
The documentation is pretty unclear on how to do this. It mentions labels, but not much else.
How can I achieve a similar result with this new system?
Answer by Chris-Ender · Sep 07, 2021 at 10:14 AM
Hi @caleidon
Yes, assigning all YAML files the same label in the Addressables Group Window allows to load all assets with this labels from remote with one command.
Depending on your purpose with addressables you might get rid of the intermediate step with the YAML files when assigning the sprites to several groups, e.g. for high and low performance PCs. Very helpful for me was the sample code on
https://github.com/Unity-Technologies/Addressables-Sample
and you should not use old versions of the Adressable package.
Greetings Chris
Your answer
Follow this Question
Related Questions
Scriptable object meta info is hidden, where did it go? 1 Answer
I'm using 4.5.4f1 version of Unity FREE and I can't find ANY assets. 1 Answer
Help I Opened An Asset But Can't Get Back 0 Answers
How to remove an asset package 1 Answer
Addressables - Use Asset Database (faster) - Not loading assets within a folder 1 Answer