How to access variables from UDataAsset in Plugin (DLC)

So I’d like to have a Plugin (DLC) that has texture uassets in it that I will later load with StreamableManager.RequestAsyncLoad . The textures need to be packaged into the Plugin and might not always be available if you do not have the DLC.

Previously I was including links to these textures in GameInstance with UPROPERTY(EditAnywhere, BlueprintReadWrite) TSoftObjectPtr<UTexture2D> and then just accessing GameInstance later.

An issue is if I keep those references the textures will get automatically added to the main packaged build instead of the Plugin (DLC).

Instead I have attempted to move the references into a UDataAsset that is contained in the Plugin. This works for packaging as the textures are now in the Plugin and not the main game however I do not know how to access these references in c++.

If I attempt to create a link to this UDataAsset in something auto loaded like GameInstance or PlayerController then this link causes the textures to once again get packaged into the main game and not the Plugin.

Any idea how I can access these textures if the plugin exists without packaging them into the main game?

I just tried accessing the Plugin UDataAsset using ConstructorHelpers::FObjectFinder in PlayerController and Unreal caught wind of what I was trying to do and packaged the textures referenced in the UDataAsset in the main build instead of the plugin build.

Ok I figured it out:

FStreamableManager AssetLoader;
	FStringAssetReference AssetRef(FPaths::ConvertRelativePathToFull("/SerenePack/Blueprints/SereneContent.SereneContent"));
	SereneDataAsset = Cast<USereneDataLinks>(AssetLoader.LoadSynchronous(AssetRef));

That will give me access to the UDataAsset (SereneDataAsset) and does not automatically package the textures referenced to main game but instead the plugin.

Of course this will crash the game if the plugin doesn’t exist so you need to check for that first and all is good!