Last active
January 28, 2021 09:01
-
-
Save sephirot47/e09077963318fa05660c to your computer and use it in GitHub Desktop.
UE4 Set-Change Material
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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