Hello, all
I have a class that during its initialization creates a singleton List<> and populates it with objects that represent options for things the rest of this class will do later. The class runs in both editor and game modes (that is, it has the [ExecuteInEditMode] attribute).
The List<> is built during my initialization method, and after I’ve added all the default options I invoke a virtual method called lateInitialiation() that can be overridden by subclasses to add their own options.
This all works just fine if the subclass has an instance attached to a GameObject in the scene. Unfortunately, my class also has a fairly complex custom Inspector, and that Inspector is lost if a subclass doesn’t also implement at least a trivial version of the custom Inspector.
What I’d really like to do is to have external classes be able to identify themselves to my class in such a way that I can actively invoke a static factory method in the third party class. The ideal goal is that an extension to my class would not be a direct subclass, but would in fact be a static class that has to be compiled into the project but doesn’t have to ever be instantiated in the scene.
The reason I’m seeking to do it this way is that the extension process is literally just a matter of populating constants for procedural geometry into a data object and then adding that data object to the List<> in my main object. The List<> itself is a singleton, so static factory methods to populate it work well.
I’m thinking that I might be able to achieve this by creating a custom Attribute that third-party classes can attach to themselves at the class or method level. Is this the “right way” to achieve what I need? Or is there a better way?
Thanks for any advice on “best practice”.