I’m making an editor tool and I want it to be stupid simple. Basically I want to stop the user from manually modifying the amount of entries in the list in the inspector, and instead, populate it automatically whenever the user adds or remove a class “Bar” component on the object holding the class “Foo”.
Ideally, I’d like something like OnComponentAdded or OnComponentRemoved.
The current workaround that I found was to use the editor’s update method and check if the components have changed every frames. Thing is, I intend on having a lot of objects holding class “Foo” and I’m curious as to wether or not there’s a more efficient way.
So far it’s triggering when the component is added, which is great. I’m adding the component to the list just fine. However OnValidate isn’t called when the component is removed.
I tried adding OnValidate to the class holding the list as well, hoping that when the user removes a class “Bar”, since the list changes its entry from class “Bar” to “Missing (Entry)”, that OnValidate would fire. No luck.
Any ideas how I could cover the OnComponentRemoved scenario?