# Finding texture2d from a fstring at runtime

**URL:** <https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908>\
**Category:** Editor Scripting\
**Tags:** Variable, unreal-engine, CPP, question\
**Created:** [December 21, 2018, 9:33am UTC](https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908 "2018-12-21T09:33:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Redsett](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Redsett](https://forums.unrealengine.com/u/Redsett)\
**Post date:** [December 21, 2018, 9:58pm UTC](https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908/3 "2018-12-21T21:58:19Z")

</div>

I found the solution here:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

header file:

```
template <typename ObjClass>
static FORCEINLINE ObjClass* LoadObjFromPath(const FName& Path)
{
	if (Path == NAME_None) return NULL;
	//~

	return Cast<ObjClass>(StaticLoadObject(ObjClass::StaticClass(), NULL, *Path.ToString()));
}

static FORCEINLINE UTexture2D* GetTexture2DByName(const FName& Path)
{
	if (Path == NAME_None) return NULL;
	//~

	return LoadObjFromPath<UTexture2D>(Path);
}

```

C++ file:

```
GetTexture2DByName(FName(*someFStringVariable));
```

---

_[View the full topic](https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908)._
