Hello, I am doing some serious profiling and it would be really benificial if I could query wether or not a MeshFilter
is using .mesh
or .sharedMesh
.
So far I have not found anything helpful in that regard, maybe someone knows how?
Hello, I am doing some serious profiling and it would be really benificial if I could query wether or not a MeshFilter
is using .mesh
or .sharedMesh
.
So far I have not found anything helpful in that regard, maybe someone knows how?
This is a good question! I made a sample project to see how you can check if your mesh is using a sharedMesh or its own mesh. [76454-sharedmesh.zip|76454]
Each unity object has its own instance id, so to check if two objects references the same you could compare their instance id. So in the sample I look for all MeshFilters active in the scene and add all sharedMesh instances ids into a HashSet to see how many different Meshes my scene has.
Note that if you want to see what mesh the MeshFilter is using you have to look at the sharedMesh property MeshFilter.mesh will return a clone of the sharedMesh, and it is used by my sample code to clone some meshes.