How can I remove an object from an asset?

I can call AssetDatabase.AddObjectToAsset to add something to a prefab. How can I remove one part but leave the rest in tact and still “connected” to clones that might be using the remaining stuff inside?

According to here you can overwrite the file, but indexes might be messed up. Ideally there would be an AssetDatabase.RemoveObjectFromAsset type of call.

You can simply call UnityEngine.Object.DestroyImmediate(objectInAsset, true). You also need to hit Save in the editor after doing this (calling AssetDatabase.SaveAssets() might work too) for the change to take effect.

At least, I have used this successfully when dealing with many separately-referenced meshes in one .mesh file. In case it matters, I was using Unity 3.5.2 and the project was set to store all assets in text format.