I’m using a slightly modified version of the combinemeshes example in the documentation. This is attached to an empty gameobject that has the nested meshes as children which then get combined.
This works, and I’m only using it to test the feature. I’m actually going to do two separate meshes. The question is:
How can I retain the original pivot relationship and materials.
The original child of the empty game object with the code on it has its pivot offset for use with a rig, but when I use combinemeshes the pivot gets set to the center of the empty gameobject parent.
Any clues?
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
int i=0;
while(i<meshFilters.Length)
{
combine_.mesh = meshFilters*.sharedMesh;*_
function CombineMeshes (combine : CombineInstance, mergeSubMeshes : boolean = true, useMatrices : boolean = true) : void
If mergeSubMeshes is true, all the meshes will be combined to a single submesh. Otherwise each mesh will go into a different submesh. If all meshes share the same material, set this to true.
So to get the materials to stay I though CombineMeshes(combine,true) would work. Which is a the problem I am having. I added the false second argument and fixed the syntax error from the doc code to make the code below. Unfortunately the combined material only has one material. my original objects had two different materials. Does anyone know how to keep multiple materials with combineMeshes,
public class Combine2 : MonoBehaviour {
void Start() {
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
int i = 0;
while (i < meshFilters.Length) {
combine_.mesh = meshFilters*.sharedMesh;*_