- Home /
combined mesh showing on different screen location
4 total Game object two cubes and two sphere. I made cube as parent and remaining three sphere and cube as child. On Parent I applied this script using this link to combine meshes in order to reduce draw calls and optimize performance.
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class CombineMsh : MonoBehaviour {
void Start()
{
Debug.Log(transform.position);
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
int i = 0;
while (i < meshFilters.Length)
{
combine[i].mesh = meshFilters[i].sharedMesh;
combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
meshFilters[i].gameObject.active = false;
i++;
}
transform.GetComponent<MeshFilter>().mesh = new Mesh();
transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine);
transform.gameObject.active = true;
Debug.Log(transform.position);
}
}
But as play the unity position of the cobmine mesh position become change on screen but not actually. Means gameobject are showing far from the orginal position while position acutally the same i have log the position. Before combining the mesh and after cobmining the mesh position are same but objects are showing on different location why?
Your answer
Follow this Question
Related Questions
Merging meshes at runtime - upside down normals? 0 Answers
Procedurally Generating a Non-Contiguous Mesh 0 Answers
How to use the script -- "MeshCombineUtility" ? 1 Answer
Manual Batching 0 Answers
Using CombineMesh with point topology? 0 Answers