That is all. Without bothering to enumerate the reasons, just putting out a feature request. Bump this thread if your project is wanting this too.
+1 for this.
+1
I had to spend 1 whole week developing an addressable pre-loading system because they don’t have such a basic feature. I understand you should aim to load all of your stuff asynchronously, but there are some cases when you need synchronous stuff, specially when you are using a game engine that is fully synchronous.
We brought this up to the team, and wanted to pass along an example on how to do this from our repositories: GitHub - Unity-Technologies/Addressables-Sample: Demo project using Addressables package
I tried to reproduce this into my project but didn’t work.
Also, the asset may not load after I call LoadAsset(), so it return a null value (and then I need to build a system around this).
Of course I understand that some asset can be loaded from a cdn or similar, and a sync load can make some troubles, but not every asset need (and can) to be loaded asynchronously.
I’m working on a card game, and i have some little scriptable objects (like card data, animation data etc…) and some big assets (artwork, generic images etc…). So I need a sync and async method to handle my data.
I can preload all my assets, but its a bad choice.
I tried this out and had some issues too, but with the complexity of it I didn’t spend enough time to figure it out. Honestly I think the whole system needs to be rethought somewhat.
We do use this here in our studio (with some custom patches), but it’s very outdated. An exemple would be that we still suffer from very long loading times when entering play mode since the sync version has not been updated since the rework that fixed that in 1.11.2.
Also possibly unrelated, we do have increasingly alarming numbers of CRC Mismatch issues when building that we can’t track.
It would be nice if the repo was updated a bit more often as it is increasingly difficult for us to patch it ourselves (as the addressables become a more and more complex beast).
You’re not alone with that:
https://discussions.unity.com/t/806258
+1
Serializing a texture with protobuf-net and loading it with Addressables:
[ProtoContract]
public class ItemTemplate
{
[ProtoMember(2)]
private string _textureGuid;
[ProtoIgnore]
public Texture2D Texture;
#if UNITY_EDITOR
[ProtoBeforeSerialization]
void SerializeTexture()
{
var path = AssetDatabase.GetAssetPath(Texture);
_textureGuid = AssetDatabase.AssetPathToGUID(path);
}
#endif
[ProtoAfterDeserialization]
async void DeserializeTexture()
{
#if UNITY_EDITOR
if (Application.isPlaying)
{
Texture = await Addressables.LoadAssetAsync<Texture2D>(_textureGuid).Task;
}
else
{
var path = AssetDatabase.GUIDToAssetPath(_textureGuid);
Texture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
}
#else
Texture = await Addressables.LoadAssetAsync<Texture2D>(_textureGuid).Task;
#endif
}
}
What it could look like with sync API*:
[ProtoContract]
public class ItemTemplate
{
[ProtoMember(2)]
public Texture2D Texture;
}
*and this reusable piece of code
public class ProtoConverterTexture2D : ISerializer<Texture2D>
{
public Texture2D Read(ref ProtoReader.State state, Texture2D value)
{
return Addressables.LoadSync(state.ReadString());
}
public void Write(ref ProtoWriter.State state, Texture2D value)
{
state.WriteString(....);
}
}