Is there a better way of updating model's texture? #26
-
Suppose that I have several NPCs which share the same mesh, but I want one NPC to have a different texture. Right now, I'm doing this to change its texture without affecting others: m := npc.Mesh.Materials()[0].Clone()
m.Texture = img
npc.Mesh.MeshParts[0].Material = m Is this a correct way of doing this? (assuming that the model will always have only one material and one mesh part) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If multiple models (NPCs, in this case) share a mesh and you want to update just one of their textures, then you should clone the model, clone the mesh (which clones its mesh parts), and clone its material, yes. From there, changing the texture works as you expect. |
Beta Was this translation helpful? Give feedback.
If multiple models (NPCs, in this case) share a mesh and you want to update just one of their textures, then you should clone the model, clone the mesh (which clones its mesh parts), and clone its material, yes. From there, changing the texture works as you expect.