The View and View Module classes allow for extensive customization when displaying the items, recipes, attributes, etc. These classes allow the View to display things differently depending on the value selected.

View & View Modules

A View is a generic class that can be extended. The Item View extends View class, which is used by items to perform the following functions (and more):

  • Clear()
  • Select(bool select)
  • Click()
  • Hide(bool hide)
  • SetValue( T value )
  • Refresh()

The View will pass on these actions to its View Modules. There can be any number of View Module components. This allows different components to be mix and matched on a prefab to dynamically change the visuals when the state changes.

As an example, the Item View can be used with the components Icon Item View and Name Item View. This allows the item icon and name to be dynamically displayed on the Item View depending on the Item set.

Since these components are small they are extremely easy to write and highly reusable. In the demo scene you’ll find a few View prefabs in action, which are used in grid and list layouts. The screenshot below is an example of one.

Each View Module component is used for one purpose only and they are grouped by the view.

Item View Drawer & Category Item View Set

Views are normally used in groups. The View Drawer works with the View Module components to spawn new views and send them events such as selected or clicked.

The Item View Drawer uses a Category Item View Set object. The purpose of this object is to map an Item Category to an Item View prefab. With this setup when the Item View Drawer draws an item it knows which Item View prefab it should use. An equivalent object exists for Recipes.

The Item View Drawer invokes events which lets you listen before and after an Item View is drawn. An example use case is the Shop Menu. An item price might depend on the shop or the character, and the item doesn’t contain this information. The Shop Menu can listen to the AfterDraw event to set and display the item post-processed price.