Mesh duplication in the editor: When you duplicate an object with a procedurally generated mesh such as rubbers, Unity keeps the reference to the mesh, meaning both items share the same mesh, which is clearly not desired. A workaround was to set the mesh object of the duplicate to null, then regenerate it, which wasn't ideal.
This PR serialized the GameObject's instance ID, and compares it on Awake() against the "real" instance ID from GetInstanceID(). If the object was duplicated, it's different, and we clear and re-generate the mesh to break the reference. However there is a drawback: Instance IDs don't persist across scenes, which results in all meshes being regenerated when the scene is loaded.
For some reason, prefabs store the last mesh along with the current mesh. So all items that store their mesh in the scene would have their mesh in the scene twice. See also Unity Forum.
This PR unpacks the prefabs for items that have a procedurally generated mesh. TBH I don't see any drawback keeping those as GameObjects instead of Prefabs in the scene.
This PR addresses two annoyances:
Awake()
against the "real" instance ID fromGetInstanceID()
. If the object was duplicated, it's different, and we clear and re-generate the mesh to break the reference. However there is a drawback: Instance IDs don't persist across scenes, which results in all meshes being regenerated when the scene is loaded.