neitsa/PrepareLanding

Remove warning from unity: mesh already finalized.

neitsa opened this issue · 1 comments

When highlighting tiles on the world map, many warning (not error) are added to the log:

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Finalizing mesh which is already finalized. Did you forget to call Clear()? 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Finalizing mesh which is already finalized. Did you forget to call Clear()? 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Finalizing mesh which is already finalized. Did you forget to call Clear()? 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
Finalizing mesh which is already finalized. Did you forget to call Clear()?

This come from the FinalizeMesh call: the call should not be on the whole mesh (which already has finalized submeshes) but only on the current submesh.

fix:

    subMesh.FinalizeMesh(MeshParts.All); // rather than FinalizeMesh(MeshParts.All);

Fixed by setting submesh.finalized = false after getting the submesh.

Using subMesh.FinalizeMesh(MeshParts.All); alone doesn't work properly has only the first highlighted tile mesh is built.