How / When are Addressables better than File . ReadAllText / ReadAllBytes ?

I was wondering how are Addressablesbetter than file ReadAllText and ReadAllBytes?

When it comes to text assets, i use this:
SomeStruct someStruct = JsonUtility.FromJson(File.ReadAllText(“weaponData.json”));

Where in case of addressables, it would take:
IEnumerator SomeCoroutine()
{
AsyncOperationHandle dataHandle = Addressables.LoadAssetAsync(“weaponData.json”);
yield return new WaitWhile(() => !dataHandle.IsDone);
SomeStruct someStruct = JsonUtility.FromJson(dataHandle.Result.ToString());
}
so it takes

  • more lines
  • coroutine
  • creates async operation handle
  • creates object of type TextAsset
  • creates string

not a good deal if you ask me, but I dont know enough about addressables to be 100% sure about it.

I still use addressables to load 3D models however im not sure when should I use addressables and when File.ReadAllText and ReadAllBytes are better.

what do you think? i mainly care about performance

I don’t know if Addressables main feature should be performance. Addressables let you easily setup different locations for your assets. So, if your asset is on your harddisk, on a remote server, in your Resources folder or Streaming Assets folder doesn’t matter to the Addressables system (at least not when you don’t take a look into the black box). You simply specify an identifier for your asset and the Addressables system will do the rest (after you did the configuration stuff :wink: ).

So, if you know where your asset is located and you want to load and process it as fast as possible, I wouldn’t use Addressables for doing so.
If you want your assets testable in your editor, but later put them onto a remote server, without changing your code to load them, then use Addressables.

Did that help?