- Home /
Unable to save the mesh when RecalculateNormals() is applied to the mesh in the editor script
I created an editor script and when a button is pressed, it recalculates the normal of the mesh:
Mesh mesh = meshList[i];
mesh.RecalculateNormals();
EditorUtility.SetDirty(mesh);
AssetDatabase.SaveAssets();
All the mesh in the meshList
is shared mesh imported from fbx file under Assets/Resources folder. When I press the button, the mesh with broken normal is fixed. But when I exit the editor and come back, the mesh reverts back to the broken normal one.
Is the result of the method RecalculateNormals()
unable to be saved?
Answer by Bunny83 · Jun 20, 2016 at 12:38 AM
The mesh that is imported from an FBX can't really be changed as it's the result of the import and might get reimported in which case every changes are reset.
If you just want to use calculated normals, you can select them in the model importer.
If you really want to save manual changes on a mesh asset, you should save the mesh as a seperate mesh asset. using the AssetDatabase class