Inside a MonoBehaviour
MyComponentA I have a list of
MyComponentB (also a MonoBehaviour) like so:
This list gets populated mostly through editor scripts at edit time.
Now say that someone who is editing the scene comes along and deletes a game object that has
MyComponentB attached, and also happens to be referenced by the list above.
MyComponentA fix the list to remove null references after such a deletion? I basically want to make this automatic so that when designers delete these objects, they dont have to go hunt down which
MyComponentA referenced them and fix the list.
My naive approach was to have a circular reference from
MyComponentA (so that it knows which list it belongs in), and then unregister it properly when
OnDestroy gets called. This however doesn't work at edit time unfortunately since
OnDestroy is not called.
Thanks for your help!