Hello,
I would like to use the Combine Meshes script provided by Unity in order to optimize my game. The problem is that my parent to which I am attaching this script,after combining the meshes, it’s changing its position. I read a few answered questions
but I couldn’t understand.
@script RequireComponent(MeshFilter)
@script RequireComponent(MeshRenderer)
function Start () {
var meshFilters = GetComponentsInChildren(MeshFilter);
var combine : CombineInstance[] = new CombineInstance[meshFilters.length];
for ( i = 0; i < meshFilters.length; i++){
combine_.mesh = meshFilters*.sharedMesh;*_
combine_.transform = meshFilters*.transform.localToWorldMatrix;*_
meshFilters*.gameObject.active = false;*
}
transform.GetComponent(MeshFilter).mesh = new Mesh();
transform.GetComponent(MeshFilter).mesh.CombineMeshes(combine);
transform.gameObject.active = true;
}
How can I cache the position before combining the meshes and then restore it as for my objects to remain untouched ?