Hey,
today I wanted to see how well I can handle if a user removes a script for a ScriptableObject that was added to another ScriptableObject like this:
After some testing it seems impossible. The only way to remove an asset is AssetDatabase.RemoveObjectFromAsset, which requires an Object as a parameter. But both AssetDatabase.LoadAllAssetsAtPath and AssetDatabase.LoadAllAssetRepresentationsAtPath return null objects. This would be fine if I could delete sub assets manually but that doesn’t work either. The only way to fix this is by reassigning another SO, restoring the original script or editing the ext of the ScriptableObject.
I know this is an edge case that could easily be attributed to the users fault and be forgotten about, but I personally would love if we could get something other than null returned for missing scripts. Maybe UnityEngine.DefaultAsset or UnityEngine.MissingScript.