TilePlus Script Attributes
If you’ve done any Unity coding then you’re probably familiar with Attributes by now, such as those having to do with serialization, or those affecting inspectors. The normal Unity Tile Selection inspector only displays the fields of the Tile class and no others. But we’d like to be able to view and modify fields and properties from TilePlusBase-derived tiles.
The Tile+Brush and Tile+Painter Inspectors and underlying library functions control what you see when using the Selection and Brush inspectors. It’s a fair amount of IMGUI code. But normal humans should not have to struggle with that. So here in TilePlus land, we have several new Attributes which can be added to your code to display fields, properties, and even invoke methods or provide custom IMGUI code for functionality that the inspectors can’t handle.
The Selection Inspector,Inspector and the Brush Inspector,Inspector (and thetheir Utilityassociated Windowequivalents in Tile+Painter) use these attributes to display simple fields and properties. Fields can be modified, and the changes are saved in the Scene. Like any other change made to a scene, you need to save the scene to persist the changes. Normally, the Configuration Editor sets “Autosave” on and the save is done automatically for every change you make.
Your original TPT tile in your Project folder will never be altered. Note that field, property, and method declarations need to be public or protected to work with these attributes.
If a tooltip is provided as part of any attribute, then any normal [Tooltip] attribute will be ignored.
Display Order The display formatter organizes the various attributes in the same order as the class hierarchy for the tile. For example, a TpAnimZoneLoader tile shows information from TpAnimZoneLoader, then TpAnimZoneBase, then TpFlexAnimatedTile, and then finally TilePlusBase. In each section, Attributes are processed in the following order: • Properties with TptShowAsLabelSelectionInspector or TptShowAsLabelBrushInspector. • Methods with TptShowCustomGui • Methods with TptShowMethodAsButton • Simple fields with TptShowField • Enum fields with TptShowEnum • Object fields with TptShowObject field