public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “General”)
FString Path01;
In UE5.2 IDE, I set the value of Path01.
Path01 = “/Script/Engine.Texture2D’/Game/WebCam/Images/cat.cat’”;
Here is the code.
if (Path01.Len() > 0)
{
char* s = TCHAR_TO_ANSI(Path01);
(METHOD #1) Tex01 = Cast(StaticLoadObject(UTexture2D::StaticClass(), NULL, (TCHAR)(s)));
(METHOD #2) Tex01 = Cast(StaticLoadObject(UTexture2D::StaticClass(), NULL, TEXT(“/Script/Engine.Texture2D’/Game/WebCam/Images/cat.cat’”)));
}
Method #1 : Tex01 = NULL;
Method #2 : Tex01 = NOT NULL, it is set to cat image.
The value of “s” and the literal string in Method #2 are identical.
So I don’t understand what I am doing wrong…is the casting wrong?