S&box Wiki

DisplayInfo

The DisplayInfo library can be used to define or display information about type and type members.

Properties

The following table lists the properties of DisplayInfo, and what attributes are related to each property. In the case that multiple attributes are listed, they are in order of precedence.

Property Attribute Target
ClassName Both
Namespace Both
Fullname Both
Name TitleAttribute, DisplayAttribute Both
Description DescriptionAttribute, DisplayAttribute Both
Group CategoryAttribute, DisplayAttribute Both
Icon IconAttribute Both
Order OrderAttribute, DisplayAttribute Member
Browsable BrowsableAttribute Member
Placeholder PlaceholderAttribute Member
Alias AliasAttribute Both
Tags TagAttribute Both

Defining info for DisplayInfo

To define information for the DisplayInfo library, use the attributes listed in the table above. For example, this Item class defines the Name and Icon.

[Title( "Item" ), Icon( "luggage" )] public class Item : AnimatedEntity { // ... }

This class will have its Name as Item and Icon as luggage.

Fetching info from DisplayInfo

To get the DisplayInfo of a type or member, use the static For, ForType, or ForMember methods of Sandbox.DisplayInfo. Then, the information can be accessed as properties of the DisplayInfo. Here's an example in a class of the name 'Player Pawn':

DisplayInfo displayInfo = DisplayInfo.ForType( this.GetType() ); Log.Info( displayInfo.Name ); // Player Pawn