- Home /
How can I have multiple instances of a prefab using a Substance and SkinnedMeshRenderers
Hello!
I am having difficulty with an avatar system that utilizes substances. I have an editor that swaps between meshes, and manipulates substance parameters based on which mesh is chosen. All is fine until I duplicate or drag in another instance of the character prefab. When I change the sharedMesh and sharedMaterial on one instance, the other instance(s) change too. I tried changing the mesh instead of sharedMesh, but I get leaks. Using material instead of sharedMaterial doesn't work at all.
Sample code:
//SkinnedMeshRenderer mesh = mesh I'm replacing
//List<SkinnedMeshRenderer> meshes = other meshes
//int index = integer;
mesh.sharedMesh = meshes[index].sharedMesh
var substance = (ProceduralMaterial)mesh.sharedMaterial;
if(substance) {
substance.SetProceduralEnum("Shirt_Color", index);
substance.RebuildTextures();
}
Does anyone have a solution for this issue?
Thanks!
Your answer
Follow this Question
Related Questions
How would I create multiple planets with different settings? (Foundation layed) 0 Answers
Does anyone know how to change the Mesh in the SkinnedMeshRenderer? 1 Answer
Problem with possibly shared meshes 0 Answers
Understanding draw calls 0 Answers
SkinnedMeshRenderer only has 'sharedMesh', no 'mesh', How to modify? 1 Answer