I am studying Unity’s custom Attributes, such as ToolTip, RequireComponent, SerializeField and so forth. I am interested in looking into their source code (i.e, the class RequireComponent.cs and also who processes them). From Visual Studio I can navigate and take a look in the code.
So a while back, we’re talking like Unity 4 or 5, I started down the path of pulling this all apart. I didn’t completely document it or anything, nor explore all of it (and yes, a bit of it is closed behind closed native code). But I wanted to add many of my own features to the existing editor attribute system and did so.
How I went about it was to first create my own “SPEditor” class that hijacked all editor’s for anything that inherited from MonoBehaviour (unless that class specifically declared its own Editor script). And this was it:
Then I reflected out entry points into a lot of the internal stuff that were non-public, and did so here:
(note - this code has not been tested in 2019 versions, and if any of the reflected methods changed names, it can potentially be misleading)
With this I created an assortment of custom attributes that had extra features on top of the existing PropertyDrawer and the sort offered.
Like modifiers (attributes that ran code, but didn’t draw stuff, on a serialized field):