C++ Asset Texture2D -> Blueprint

If I understand the question correctly, you are looking to recreate in cpp what the “Import File as Texture 2D” is doing in bp? If that’s the case have you looked at what that bp node is doing in cpp? That is where I would start.

From a pure coding perspective, something seems off about TSoftObjectPtr<UTexture2D> Icon = TSoftObjectPtr<UTexture2D> FSoftObjectPath(initialBackgroundPath);

You’re constructing an FSoftObjectPath and attempting to cast it to a TSoftObjectPtr of type UTexture2D? I believe you’re missing an intermediate step which actually loads the object.

All of that being said, check this post out. This might be what you’re looking for Declaring a texture variable - Programming & Scripting / C++ - Epic Developer Community Forums (unrealengine.com)