How to get a 2d texture with c++ from it's file path

How do I get a regular 2d texture from the folder project that is already loaded with the editor.

I already have a mechanism where I make a 2d texture out of an image and format it, but I just want to use one already made within the editor from imported images. In my editor I have a texture inside my project that is inside one of the project folders visible inside the editor and I want to get that.

So how would I get that with constructor helper or is there any other way so I get a path to the 2d texture, then I would have a variable to work with the texture and read it’s data in C++

For static meshes it’s like this:

static ConstructorHelpers::FObjectFinder<UStaticMesh> 

in this case CubeVisualAsset can be passed to the staticmesh* variable.

How would it be for 2d textures to find the texture with a path.
I also saw around you can get it with GetData() ?

But none of these show a path so how do you know in what folder it’s in.
I looked around and could not find an example.

I have working code with image wrapper to import an image from disk then I convert it to a 2d texture by setting it’s format but I don’t want that, I just want to be able to grab a 2d texture from the project folder that is loaded with the editor and it is already there. Since I have all these 2d textures and can load them easy with the editor inside the project I just want one that already is present.

Is there a constructor helper that can get the 2d texture, I looked around but could not find any.

I need the 2d texture to read the mip off of it and then get it’s pixels but for that I need a texture.

Hey @GigiK-K-K
I believe you need to physically import the texture separately rather than give a path, so Unreal would handle all the file path specifics and you’ll be able to reference it.
Here’s a link to some 4.27 documentation to get you started:

The next step after that is using them, and it should be in the next sections of the docs.

I hope this helps!

Thanks for the help and I will look into it.
I actually got it
static ConstructorHelpers::FObjectFinder Texture(TEXT(“Texture2D’/Game/textures/Grainy_13_-512x512.Grainy_13-_512x512’”));
texture = Texture.Object;

I did physicaly import the image and create a 2d texture out of it

so Unreal would handle all the file path specifics and you’ll be able to reference it.

Yes but how would I refrence it beside with the costructor, is it any other way. So you right click on the texture and there is the copy refrence that I use with my constructor helper, but it would be interesting if this can be done in other ways as well.

Is there any other way to refrence it besides with constructor helpers ?

I use the constructor helper now and I tried to use the variable.
as such:
FTexture2DMipMap* MyMipMap = &texture->PlatformData->Mips[0];

it seems not to crash for now, but I don’t know if I’m going to get any data with the constructor helper , maybe I should use in this line just texture and not “&texture” with a pointer refrence.

For now I got

UTexture2D *texture;
static ConstructorHelpers::FObjectFinder<UTexture2D> Texture(TEXT("Texture2D'/Game/textures/Grainy_13_-_512x512.Grainy_13_-_512x512'"));
texture = Texture.Object;

 FTexture2DMipMap* MyMipMap = &texture->PlatformData->Mips[0];
````Preformatted text`

I'm attempting to load the mips.

I don’t know if this works

is there any way to log Fcolor type. Fcolor is of int type really but it’s type is Fcolor, so Fcolor is Int, it just has whole numbers.

I tried
UE_LOG(LogClass, Log, TEXT("int value %d"), PixelColor );
But I get errors and it won’t log the values inside the log.

I tried with a regular int and created a int variable that I gave a value , the value shows up in the log, but if I try the PixelColor variable it won’t work as it won’t compile.

So is there any way to log the FColor Type to see what values I get.
This way I know the texture has been loaded corectly and maybe I get some values even if it’s blank numbers at least I will see something.

I can’t know if the texture loaded with the constructor helper then accesing it’s mips is loaded properly, how can I verify the data from an FColor type.

Per haps this is another question

I never herd of cubemaps, not familiar with them, pretty interesting concept.
Are these 2d textures ? I have not been reading yet about them.