Extending A Base Class
Asset type Unity Objects refer to Unity Objects that cannot exist in the scene, that is all Unity Objects except Components and GameObjects. One such example is ScriptableObjects.
Extend AssetDrawer if an Editor is not used for drawing the class members of the drawer.
This gives you the most power to customize the drawer, and should be used when possible for the best results.
Extend CustomEditorAssetDrawer if an Editor is used for drawing the class members of the drawer.
In this case your options for customizing the drawer will be more limited, but you can still do things like add new header buttons or customize the context menu.
This is mainly used when the target asset has a Custom Editor.
For Power Inspector to know which assets should be represented by the drawer class you’ve created, you’ll need to add the DrawerForAsset attribute to the class.
When Power Inspector prepares a drawer for use inside an Inspector, it will call two methods inside the drawer class:
- First, it will call the SetupInterface method (defined in the IEditorlessAssetDrawer and ICustomEditorAssetDrawer interfaces).
- After that has finished, it will call the LateSetup method (defined in the base IDrawer interface).
All drawer class also contain a Setup method. The only job of the SetupInterface method is to take the parameters provided by Power Inspector, and to convert them into a form that the main Setup method can accept, and then call that Setup method.
You can override the Setup and LateSetup methods if you want to customize the setup phase.
IMPORTANT: If you override Setup or LateSetup, remember to always also call base.Setup and base.LateSetup!
You can override the DoGenerateMemberBuildList method to gain control over which class members to include inside the drawer. This is done through deciding which LinkedMemberInfos are placed inside the memberBuildList.
You can also override DoBuildMembers to customize exactly how member drawers are built from the memberBuildList that was previously generated by the DoGenerateMemberBuildList method.
During the execution of this method all member drawers should be created and placed into the members array.
You can use ParentDrawerUtility.BuildMembers to automatically generate members based on the contents of the memberBuildList.