# 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:** 4\
**Page:** 1

<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:33am UTC](https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908/1 "2018-12-21T09:33:34Z")

</div>

Hello, I have a FString variable that has my relative path to the uasset texture. How do I use the variable in getting the utexture2d object?

static ConstructorHelpers::FObjectFinder CrosshairTexObj(TEXT(“Texture2D’%s’”), someFStringVariablePath);

EDIT:  
Looks like that code above is just for construct. Is there something similar for runtime?

---

<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, 7:03pm UTC](https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908/2 "2018-12-21T19:03:59Z")

</div>

I don’t think Texture2D is actually needed in that.

static ConstructorHelpers::FObjectFinder CrosshairTexObj(TEXT(someFStringVariablePath);

After some more research, I believe ConstructorHelpers::FObjectFinder is not the function I’m looking for. Because it seems to be only for ObjectInitializer.

I’m getting paths from json files at run time. These paths are relative paths to already imported textures. I just need to know how to convert these FString paths that I’m getting from the json files to a texture2d.

---

<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));
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d895df8a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d895df8a](https://forums.unrealengine.com/u/anonymous_user_d895df8a)\
**Post date:** [January 8, 2019, 1:33pm UTC](https://forums.unrealengine.com/t/finding-texture2d-from-a-fstring-at-runtime/439908/4 "2019-01-08T13:33:29Z")

</div>

I want to create a Texture2D dynamically which is readable. There doesn’t appear to be any way to set the IsReadable property to true. The docs reference IsReadable, but I can’t even find it declared anywhere.
