Hello,
I posted this same question on Unity Answers a couple days ago, but had no luck there so I thought I’d try here as well.
I’m having a problem with real-time mesh editing.
I’m making a script that removes triangles from a mesh when you click them. Currently, it removes the triangle you click on and everything works great, however when I stop the game and go back to scene mode, the mesh doesn’t reset and the missing triangles in the mesh persist. Even if I start testing in game mode again, the missing triangles are still there. The only way I’ve found to reset the mesh is to entirely restart Unity. Even if I save the scene before restarting it resets the meshes to the way they should be, so it doesn’t save the edited meshes in any way. It appears to be some sort of strange bug.
Also, I’ve tried instancing a prefab of the mesh, but even then, the problem persists.
What’s causing this? It’s quite frustrating. Thanks for any help.
I’d need to see code, but it sounds like you’re modifying a mesh in Unity’s cache – and since assets(as opposed to objects in game) do not revert when you stop testing, the changes are retained.
Yes, I tried that. It had the same result, but this time it warned me that “mesh” was deprecated and that I should use “sharedMesh” instead, or something along those lines.
Hm, I’ve written a lot of procedural mesh code in Unity and have never gotten an error message of that sort. Could you post the exact error message and the code that generated it?
Ah, I missed that you’re using meshCollider.mesh. Are you trying to modify the mesh visual, or the mesh’s collision properties? If the former, you probably want to be modifying the mesh returned by MeshFilter.mesh, not the MeshCollider mesh.
OH DUH…And that, of course, solved the problem. Thanks a million, Jesse, and thanks to everyone else for your help as well . Don’t I feel dumb now, haha.