I want to change the color of the object through C ++ and not in the editor. I do this:
I set my two functions completely where I do it
AWallActor::AWallActor()
{
PrimaryActorTick.bCanEverTick = false;
ProceduralMeshComponent = CreateDefaultSubobject<UProceduralMeshComponent>("WallMesh");
ProceduralMeshComponent->bUseAsyncCooking = true;
ProceduralMeshComponent->SetupAttachment(RootComponent);
Material = CreateDefaultSubobject<UMaterial>(TEXT("Material"));
}
void AWallActor::BeginPlay()
{
Super::BeginPlay();
FColor WallColor(255, 0, 0, 255);
..............................................
FColor WindowColor(255, 255, 0, 255);
MeshSection Section;
GenerateWall(Section, WallCenter, WallSize, WallColor,
NumWindows, WindowFrameSize, WindowFrameWidth, WindowRailWidth,
WindowLeftOffset, WindowTopOffset, DistBetweenWindows, WindowColor);
ProceduralMeshComponent->SetMaterial(0, Material);
ProceduralMeshComponent->CreateMeshSection(SectionIndex,
Section.Vertices,
Section.Triangles,
Section.Normals,
Section.UV0,
Section.VertexColors,
Section.Tangents,
bCreateCollision);
}
Error:
ProceduralMeshComponent->SetMaterial(0, Material);
Exception thrown at 0x00007FFED863BE95 (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000003B0000003F.
What is wrong. Why not change the color?
User contributions licensed under CC BY-SA 3.0