# C++ Asset Texture2D -\> Blueprint

**URL:** <https://forums.unrealengine.com/t/c-asset-texture2d-blueprint/1319795>\
**Category:** C++\
**Tags:** unreal-engine, CPP, Blueprint, question\
**Created:** [October 2, 2023, 11:50am UTC](https://forums.unrealengine.com/t/c-asset-texture2d-blueprint/1319795 "2023-10-02T11:50:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![gh0stfase1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gh0stfase1/32/1194639_2.png) [@gh0stfase1](https://forums.unrealengine.com/u/gh0stfase1)\
**Post date:** [October 2, 2023, 2:35pm UTC](https://forums.unrealengine.com/t/c-asset-texture2d-blueprint/1319795/2 "2023-10-02T14:35:53Z")

</div>

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)](https://forums.unrealengine.com/t/declaring-a-texture-variable/7666)

---

_[View the full topic](https://forums.unrealengine.com/t/c-asset-texture2d-blueprint/1319795)._
