RealDocs

UKismetRenderingLibrary::ImportFileAsTexture2D

function Engine Blueprint Since unknown
#include "Kismet/KismetRenderingLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallable

Description

Loads an image file from disk and creates a new transient Texture2D from it.

Caveats & Gotchas

  • Returns nullptr if the file can't be found, isn't a supported format, or fails to decode — always check the result before using it.
  • The resulting texture is transient and not saved as an asset; it exists only in memory for the current session unless you explicitly package it.
  • Reads from an arbitrary filesystem path, so never pass unsanitized user or network input as Filename in a shipping title.

Signature

static UTexture2D* ImportFileAsTexture2D(UObject* WorldContextObject, const FString& Filename)

Parameters

Name Type Description Default
WorldContextObject UObject* World context used to resolve the current world.
Filename const FString& Absolute path to an image file on disk.

Return Type

UTexture2D*

Example

Import an image file as a texture C++
UTexture2D* Loaded = UKismetRenderingLibrary::ImportFileAsTexture2D(this, TEXT("C:/Temp/icon.png"));
if (Loaded)
{
    MyImageWidget->SetBrushFromTexture(Loaded);
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.