MeshSmoother not destroying original mesh #9307
Labels
Feature Request
Feature request from the community
Won't Fix
A real bug, but Triage feels that the issue is not impactful enough to spend time on
Milestone
Describe the problem
I am currently using the MeshSmoother together with the Outline shading using the MRTK2 shader. In our scenario, this needs to be done and undone programatically and leaving the original mesh untoched. It just so happens that when the MeshSmoother component is destroyed, its OnDestroy method wipes out the object mesh and I can't show the original object anymore.
Describe the solution you'd like
MeshSmoother.OnDestroy not having the desctructive behavior.
Describe alternatives you've considered
I have implemented a solution and I'll contribute it if you need to.
In broad strockes, when doing the "MeshReference" to count references to the mesh, I also keep the original "shared mesh" reference inside it. In the OnDestroy() method, in the case there's no more references to it (which is our case), on top of destroying the current mesh, I re-instantiate the original one: meshFilter.mesh = Instantiate(meshReference.InitialMesh);
Additional context
I realize that the smoothed normals are written to the UV2 channel and I might as well just keep them until the object is actually destroyed but I don't think the fix I suggested as any downsides and has the upside of being able to safely remove a MeshSmoother component without issues.
The text was updated successfully, but these errors were encountered: