Hi everyone, 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);
}
}
}
That’s cool, thanks a lot, but is it possible to do this by clicking some UpdateMapAssets button in the editor, I saw that you can only use static methods with [MenuItem]?
You can use a context item if you want to do it quickly (Unity - Scripting API: ContextMenu). The context item will also be visible if you right click on your component in the inspector.
Otherwise you can build a custom inspector that adds a button to do this, yes.
I tried your code, the fact is that I need to record the positions of assets, and in the code, that is, the position of the object on which the script weighs “_mapAssetsPositions.Add(GameObject.transform.position);” Maybe I misunderstood you
Maybe I don’t need it. I use Addressables for open world streaming. I need to get references to the map’s prefabs (AssetReference) and its positions, then divide the world into chunks, and then in the Update go through all the AssetReference in the chunk and compare the position of the player and the prefab