Unity Addressable | Adding positions of all assets to the list without loading into RAM

38 views Asked by At

I need to create a list of Addressable asset positions from the group in order to load them later in real time when approaching, but I can't fully load them into memory, because the entire map takes 2 GB, which is unacceptable on mobile, now despite the fact that I load and unload separately, they are loaded into RAM That's it

public class AddressableTestRuntimeLoad : MonoBehaviour
{
    [SerializeField] private List<AssetReference> _mapAssets = new();
    [SerializeField] private List<Vector3> _mapAssetsPositions = new();

    public IEnumerator Start()
    {
        var loadAssetLocationsOperation = Addressables.LoadResourceLocationsAsync("map");

        yield return loadAssetLocationsOperation;

        foreach (IResourceLocation location in loadAssetLocationsOperation.Result)
        {
            AssetReference assetReference = new(location.PrimaryKey.ToString());
            _mapAssets.Add(assetReference);

            var instantiateAsset = assetReference.InstantiateAsync();

            yield return instantiateAsset;

            _mapAssetsPositions.Add(instantiateAsset.Result.transform.position);
            Addressables.Release(instantiateAsset);
        }
    }
}

I tried loading all assets at once via Addressables.LoadAssetsAsync and Addressables.LoadResourceLocationsAsync separately instancing assets to the scene

0

There are 0 answers