Hello!
I’m making a plugin to handle landscape proxies, for this im implementing a class “Tile” Which is supposed to store date appropriate for each proxy. I would like to have a default material which I have already created, what I have so far looks like this:
.h
#include "CoreMinimal.h"
#include "LandscapeStreamingProxy.h"
//Creating material
#include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
class PROCEDURALWORLD_API Tile
{
public:
Tile();
Tile(TObjectPtr<ALandscapeStreamingProxy> inProxy);
~Tile() = default;
TObjectPtr<ALandscapeStreamingProxy> streamingProxy = nullptr;
UMaterial* myMaterial;
.cpp
Tile::Tile(TObjectPtr<ALandscapeStreamingProxy> inProxy)
{
streamingProxy = inProxy;
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("Material'/Game/Test_assets/M_grassMaterial.M_grassMaterial'"));
if (Material.Object != NULL)
{
myMaterial = (UMaterial*)Material.Object;
UE_LOG(LogTemp, Warning, TEXT("Value tx: %s"), *myMaterial->GetName());
}
}
However, when I try to create Tiles the engine crashes and the message I get is that FObjectFinders can’t be used outside of constructors.
What am I doing wrong here?