How AssetBundles work?

I want to create item data that is loaded asynchronously via UDataAsset and use AssetManager
link - epic games tutorial with time
I get the data correctly, but I found out about AssetBundles, which allows you to upload only what is necessary, for example, to split the data for the interface and for the game world.

class MYGAME_API UDCM_ItemDataTest : public UPrimaryDataAsset

	UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Item", meta = (AssetBundles = "UI"))
	TSoftObjectPtr<UTexture2D> ItemData2d;

	UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Item", meta = (AssetBundles = "InGame"))
	TSoftObjectPtr<UStaticMesh> ItemDataMesh;

but when called to load only (UI), I can still read other(InGame) data.

It is possible that some other asset is causing that particular static mesh to be loaded. Just because you didn’t want it to be loaded because of this asset you’re loading doesn’t mean that some other asset didn’t need it.

Once the content (like a static mesh) is loaded, it is reference-able from all the places with a soft object pointer that refer to that content’s path.

This could be because you did a bundle operation on another primary asset or because some other asset has a hard reference to that content. It could even be because you happen to have that static mesh (or a blueprint using that static mesh) open in the Editor when you launch PIE!

The reference viewer tool will be one of your best resources for figuring out how your content is actually getting used and potentially getting loaded. I also find that running standalone or a fresh Editor session to be ideal when debugging these sorts of things.

you’re right. thanks. I uploaded a new texture and added it to dataasset. now it works as expected.

I have one last question left. how unused objects are unloaded. for example, I uploaded this texture to a 3d widget, I showed it to the player and deleted it (3d widget). do I need to do anything to get this texture unloaded from memory? (now it looks like once you download it, it remains in memory (always available))

I noticed that there is an unload primary asset method, but I don’t quite understand what it does.

In general this is just the Garbage Collector doing it’s thing. If you’re interested in how that works there are probably some good write ups online somewhere if you do some simple searches. It’s just a more complicated subject than what I can do a reasonable description of here.

I think that UnloadPrimaryAsset just undoes LoadPrimaryAsset because Load works in a way that’ll keep the asset loaded until you call Unload. I think. This would be similar to Actors requiring you to call Destroy to get rid of them since they’re always referenced by the UWorld they were spawned in.

thanks for sharing. this has advanced my research