Skip to content

Instantly share code, notes, and snippets.

@sephirot47
Last active January 28, 2021 09:01
Show Gist options
  • Save sephirot47/e09077963318fa05660c to your computer and use it in GitHub Desktop.
Save sephirot47/e09077963318fa05660c to your computer and use it in GitHub Desktop.
UE4 Set-Change Material
void ChangeMaterial(UMaterial *material)
{
TArray<UStaticMeshComponent*> meshes;
GetComponents<UStaticMeshComponent>(meshes); //Get all the mesh components
for (UStaticMeshComponent *mesh : meshes)
mesh->SetMaterial(0, material); //For each mesh component, set the material (the 0 is the element index of the material)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment