cesium-unity icon indicating copy to clipboard operation
cesium-unity copied to clipboard

Deleting `Cesium3DTileset`, then undoing has irreversible consequences

Open j9liu opened this issue 1 year ago • 1 comments

I accidentally deleted a Cesium3DTileset in one of the sample levels (though it doesn't matter which), and tried to undo it. But this messes up a lot.

Firstly, the console gets spammed with these error messages:

This Mesh Collider is attached to GameObject at path 'CesiumGeoreference/Cesium World Terrain/[url]/Mesh 0 Primitive 0' with Mesh '' in Scene '01_CesiumWorld', but the mesh doesn't have any vertices.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Then, as tiles attempt to reload, many of them will appear purple (indicating a material with errors)... image

... and some of them will appear un-georeferenced. In this screenshot, the purple streaks in the sky are floating tiles. image

I imagine that undoing the deletion is pretty disastrous for the state management of Cesium3DTileset, but I believe it's because the delete operation is recording the deletion of the child game objects -- even those marked HideAndDontSave. So when I undo the operation, it adds back all of those game objects. This prevents the tileset from properly cleaning up when it is disabled and reenabled.

I don't know if this can be prevented, but hopefully there's a way to intercept the undo operation and prevent the tiles from being reattached?

j9liu avatar Feb 19 '24 15:02 j9liu

I'm seeing similar errors if the tileset is under a parent object that is disabled / enabled. Because the tileset itself is not directly disabled, it doesn't perform the necessary cleanup after it is re-enabled...

j9liu avatar Jan 30 '25 15:01 j9liu