Please help. I tried everything.
Please excuse the formatting. I’m writing this directly in the text field. For a UStaticMeshComponent you can call the function SetStaticMesh(UStaticMesh* inMesh). I’ve written a quick setup below.
//in Demo.h
UCLASS()
class ADemo : public AActor {
GENERATED_BODY()
private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
//Static mesh component
UStaticMeshComponent* Mesh;
public:
//Default constructor
ADemo();
//Sets the mesh to a new static mesh
UFUNCTION(BlueprintCallable)
void SetMeshComponentMesh(UStaticMesh* inMesh);
}
and then in demo.cpp
#include "Demo.h"
ADemo::ADemo()
: Super() {
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->SetupAttachment(RootComponent);
}
void ADemo::SetMeshComponentMesh(UStaticMesh* inMesh) {
Mesh->SetStaticMesh(inMesh);
}
then in your blueprints on your input just call that function.