FObjectFinder doesn't load asset and I don't know why

Thank you for your reply, in fact after I take a better look into the unreal framework source code there is a function that checks if it is called inside the constructor, this information is such interesting, but the fact is that I already tried to use the code in constructor and I had no success.

After a lot of more time expended looking into source code and unreal docs I learned how to copy asset reference trough unreal ui interface and noticed the wrong file path and that was the issue I was having.\

imagem_2023-07-15_233337633

Mesher::Mesher()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you dont need it.
	PrimaryActorTick.bCanEverTick = true;

	static ConstructorHelpers::FObjectFinder<UStaticMesh> meuMesh(TEXT("/Engine/BasicShapes/Sphere.Sphere"));

	if(meuMesh.Succeeded())
	{
		GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, TEXT("Asset loading works!"));

		umesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyPrettyCube"));
		
		bool loaded = umesh->SetStaticMesh(meuMesh.Object);

		if(loaded)
		{
			GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, TEXT("Success in Asset assign!"));
		} else {
			GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, TEXT("Asset assign has failed!"));
		}

	} else {
		GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, TEXT("Fail in mesh loading!"));
	}
}

Now I’ll take more a look at the other example code that you provided, Thank you for your contribution. :slight_smile:

2 Likes