Hertzole 2 Report post Posted July 20, 2016 Hi, I'm playing around with some runtime editing and I am trying to set a material on a specific face but I can't really figure out how. I basically copied the code from the RuntimeEdit script and added a basic way to try and set the material for the selected face. This is currently my code for doing this. if (Input.GetKeyDown(KeyCode.Alpha1)) { if (currentSelection.IsValid()) { Debug.Log("Set material"); currentSelection.pb.SetFaceMaterial(currentSelection.pb.faces, testMaterial); RefreshSelectedFacePreview(); } } The most confusing part about the "SetFaceMaterial" function, to me at least, is that it was an array of pb_Face. How am I supposed to set the face I want to apply a material to? Share this post Link to post Share on other sites
karl 321 Report post Posted July 20, 2016 SetFaceMaterial accepts an array of faces to set the material for. If you just have one your array would just have a length of one, ex: currentSelection.pb.SetFaceMaterial(new pb_Face[1] { currentSelection.pb.faces[0] }, testMaterial); currentSelection.pb.ToMesh(); // rebuild the submeshes with new face materials currentSelection.pb.Refresh(); // rebuild the normals, tangents, uvs, etc. 1 Hertzole reacted to this Share this post Link to post Share on other sites
Hertzole 2 Report post Posted July 20, 2016 SetFaceMaterial accepts an array of faces to set the material for. If you just have one your array would just have a length of one, ex: currentSelection.pb.SetFaceMaterial(new pb_Face[1] { currentSelection.pb.faces[0] }, testMaterial); currentSelection.pb.ToMesh(); // rebuild the submeshes with new face materials currentSelection.pb.Refresh(); // rebuild the normals, tangents, uvs, etc. Ah, I see. Thanks for the info, but I actually used: currentSelection.face.SetMaterial(testMaterial); Thanks for the extra lines "ToMesh();" and "Refresh();"! That was the thing I was missing when I tried to get SetMaterial to work. 1 karl reacted to this Share this post Link to post Share on other sites