Hello,
I’ve turned on Prebake Collision Meshes in my Player Settings, and now the build fails with the errors message:
Failed to create Physics Mesh from source mesh "pb_Mesh5917382". One of the triangles is too large. It's recommended to tesselate the large triangles.
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler ()
Since this is a Pro Builder mesh I can’t easily find it - the project has multiple scenes each with a bunch of ProBuilder meshes. And to make matters worse when playing the game in Editor I get no warnings or errors about it.
Is there ANY way for me to find which mesh is causing this? I can’t even run the game in editor and search the hierarchy since it gives me the mesh name, not the game object name it originated from.
The “Feature Request” tag is really me asking if we can make this error any clearer.
I’ve hit this before… usually it’s pretty obvious. I think the triangle has to be pretty humungous, like 100+ in size, and generally you don’t have many of those.
You could also use that mesh name (pb_Mesh5917382) to write a little editor script to find which GameObject the mesh is on. Here, I’ll get you started on a little code loop you can use:
// put this code in a static function to call from a menu item
// (see how to do editor scripting and use the MenuItem() attribute)
// when your scene is present.
//
// This code will iterate all MeshFilters, printing the name of the
// GameObject they're on, and the name of the mesh asset
var allMeshFilters = FindObjectsOfType<MeshFilter>();
foreach( MeshFilter filter in allMeshFilters)
{
Mesh mesh = filter.mesh;
Debug.Log( "Mesh on GameObject " + filter.name + " is called " + mesh.name);
if (mesh.name == "pb_Mesh5917382")
{
Debug.Log( "Gameobject " + filter.name + " seems to be the one you want!");
}
}
Better living through editor scripting!
Keep in mind there may be more than one triangle that is too large.
Thanks for the suggestion! I ended up making something quite similar - iterating through all the scenes included in the build and checking all the meshes inside - unfortunately that returned absolutely nothing Might be due to ProBuilder and how it names and updates its meshes (maybe it refreshes the names when being built, who knows - making another build gave me the same error with a different mesh name!).
foreach( EditorBuildSettingsScene buildSettingsScene in EditorBuildSettings.scenes )
{
if( buildSettingsScene.enabled )
{
Debug.Log( $"Checking scene: {buildSettingsScene.path}" );
EditorSceneManager.OpenScene( buildSettingsScene.path, OpenSceneMode.Single );
MeshFilter[] meshFilters = FindObjectsOfType<MeshFilter>( includeInactive: true );
Debug.Log( $"- Found mesh filters: {meshFilters.Length:N0}" );
foreach( MeshFilter meshFilter in meshFilters )
{
Mesh mesh = meshFilter.sharedMesh;
if( mesh != null &&
mesh.name == "pb_Mesh5917382" )
{
Debug.LogWarning( $"- Found invalid mesh on game object: {meshFilter.GetFullPath()}", meshFilter );
}
}
}
}
Regardless I still think this type of error should be better traced in the build errors
Interesting. Yeah, those PB mesh names get renamed at “some random points” and I don’t understand when. The renames can be very annoying with source control, producing extra diffs.
Try this instead:
- you have the mesh
- iterate the triangles
- for each triangle:
—> calculate the area of the triangle from the points involved
—> or maybe just compute the total edge lengths??
If you see one bigger than size XXX, print the GameObject name
You could print them all and sort them by size too.