Attribute View
An Attribute View displays one resolved Attribute value, such as an Iron Sword’s Attack or current Durability. Use it when an Item Description, comparison panel, or other UI needs a reusable value row instead of Item-specific presentation logic.
The surrounding Item Description or binding chooses the Attribute. The Attribute View holds the resulting AttributeInfo, and its Attribute View Modules draw the name, value, color, or conditional state.
Before you begin
Confirm that:
- the Attribute is declared in the correct collection on an Item Category;
- the selected Item Category, Item Definition, or Default Item supplies the intended value;
- a project-owned UI Designer schema has been duplicated and spawned; and
- an Item Description or another parent component exists to supply an Attribute at runtime.
For the shared example, declare Attack as an integer Item Definition Attribute on Weapon and Durability as an integer Item Attribute. Iron Sword and Fire Wand can then share the same Attribute View prefabs while showing their own definition and runtime values. Health Potion should not receive either Weapon-only row.
Create an Attribute View
- Open Tools > Opsive > Ultimate Inventory System > UI Designer.
- Select the Attribute View tab and open Create.
- Set Parent Transform when the new View should be created under a particular UI layout, then create it from the duplicated project schema.
- Open Edit and select the generated Attribute View.
- Add only the Attribute View Modules required by this row, then assign each module’s Text, Image, or GameObject references.
- Save the project-owned prefab.
- Assign the prefab directly to its parent UI, or map an Attribute name to it through a Category Attribute View Set.
The Attribute View’s base Target Graphic is useful when a surrounding View Slot needs a target. Assign Canvas Group only when the whole View must be hidden and made non-interactable through the View API.
Choose a module for the value
The released Version 1 runtime supplies these Attribute View Module types:
| Module | Use | Important fields and behavior |
|---|---|---|
| Value Attribute View | Display an integer, string, or another value through its text representation. | Assign Attribute Text. Clear If Null Value is disabled by default; enable it when the resolved value may be null or empty. |
| Float Value Attribute View | Display a float with controlled precision. |
Assign Value Text. Format defaults to {0:0.00}. Values lower than Clear Below Threshold, which defaults to 0, clear the text; a value equal to the threshold is still displayed. A non-float Attribute displays ?. |
| Name Value Attribute View | Display the Attribute name and value in separate controls. | Assign Attribute Name Text and Attribute Value Text. Enable Clear If Null Value when a missing value should clear both controls. |
| Show Hide Attribute View | Show one set of GameObjects and hide another according to a numeric comparison. | Configure Show, Hide, Compare Operator, Compare Value, and Pass If Null. Use it only with values that can be converted to a number. |
| Value To Color Attribute View | Map an integer or enum value to a color. | Assign Icon and the indexed Colors array. Out-of-range or unsupported values use Missing Color. Disable On Clear is disabled by default. |
Use Value Attribute View for integer Attack or Durability; there is no separate integer runtime module class in released Version 1. Use Float Value Attribute View only for an Attribute declared as float, not merely because the desired text contains a decimal point.
Each module must clear every visual it changes. Attribute Views and their parents may be pooled or reused, so stale text and colors otherwise remain when selection changes.
Bind Attribute names by category
For an Item Description that should build its rows from the selected Item:
- Create a set with Create > Ultimate Inventory System > UI > Category Attribute View Set.
- Add a Weapon entry. Map the exact name
Attackto the Attack Attribute View prefab andDurabilityto the Durability prefab. - Add a Consumable entry only for values that Health Potion should show, such as
Descriptionwhen the project presents that value as an Attribute row. - On the Item Description, add or select Category Attribute View Set Item View Module.
- Assign the set to Category Attribute View Set and assign the layout transform to Attribute UI Parent.
- Bind the Item Description to the Inventory Grid or other selection source.
At runtime, the module checks every set entry whose Item Category contains the selected Item. For each exact Attribute name it can find, it creates the mapped prefab below Attribute UI Parent and gives the Attribute View both the resolved Attribute and the selected ItemInfo.
Broad and narrow category entries can both contribute rows. For example, an All entry can supply Description while the Weapon entry adds Attack and Durability. Avoid mapping the same Attribute name in both entries unless two rows are intentional.
Match the View to Attribute scope
The Attribute View presents the value it receives; it does not choose where that value is stored.
| Scope | What the View should demonstrate | Example |
|---|---|---|
| Item Category | One resolved value that describes a category and may be inherited by child categories. | A Weapon CategoryIcon row in a category-oriented panel. |
| Item Definition | A value shared by Items created from that definition. | Iron Sword and Fire Wand display their own Attack values. |
| Item | A value that may differ for each mutable runtime Item. | Two Iron Sword Items display different remaining Durability. |
The Default Item on an Item Definition provides the starting Item-level value. If Durability must change independently, Weapon must be configured so those runtime Items are mutable and unique. Changing the visual prefab does not make an immutable Item editable.
When a runtime Attribute changes, refresh or redraw the owning Item Description. A View that still holds the same Attribute can also be refreshed, but the parent remains responsible for selecting the correct Item and removing rows that no longer apply.
Editor checkpoint
Before entering Play Mode, confirm that:
- the prefab has an Attribute View component and only compatible Attribute View Modules;
- every Text, Image, GameObject array, and optional Canvas Group reference is assigned where used;
- the module accepts the declared value type;
Attackis declared in Weapon’s Item Definition collection;Durabilityis declared in Weapon’s Item collection and initialized on each definition’s Default Item;- the Category Attribute View Set uses the exact Attribute spelling and a prefab containing Attribute View;
- Weapon maps to the Attack and Durability rows while Consumable does not; and
- the Item Description has valid Category Attribute View Set and Attribute UI Parent references.
Verify in Play Mode
- Open Bag and select Health Potion. Confirm that no empty
AttackorDurabilityrow is created. - Select Iron Sword. Confirm that its definition-level
Attackand current Item-levelDurabilityuse the expected labels and formatting. - Select Fire Wand. Confirm that both values are replaced and no Iron Sword text remains.
- Change one Iron Sword Item’s
Durability, then refresh or reselect it. Confirm that the row shows the new runtime value. - Select another Iron Sword or Fire Wand and confirm that its own
Durabilityhas not changed. - Select an empty slot and confirm that all Attribute View rows are removed or cleared.
- If a float row is used, test a value below, equal to, and above Clear Below Threshold, plus the largest expected formatted value.
- If a Show Hide or Value To Color module is used, test every comparison or indexed state and confirm that an unsupported value uses the intended cleared or missing presentation.
Troubleshooting
| Symptom | Check | Fix |
|---|---|---|
| No Attribute row is created | Category mapping, exact Attribute name, and selected Item’s categories | Correct the name and map the prefab under a category that contains the selected Item. |
| The row exists but its text is blank | Module UI reference, source value, and null-clearing option | Assign the Text control and confirm the selected Item resolves a non-null value of the expected type. |
A float displays ? |
The Attribute’s declared type | Use Float Value Attribute View only with float; use Value Attribute View for an integer. |
| A small or negative float disappears | Clear Below Threshold | Lower the threshold when those values should remain visible. |
| Health Potion shows Weapon rows | Category Attribute View Set entries and category inheritance | Keep Attack and Durability under Weapon rather than All or Consumable. |
| The same Attribute appears twice | Broad and narrow category mappings | Remove the duplicate mapping; all matching category entries contribute rows. |
| Changing one weapon changes another | Attribute scope and Weapon mutability/uniqueness | Keep Durability in the Item collection and use mutable, unique weapon Items. |
| A previous value remains after selection changes | Custom module Clear behavior and parent redraw |
Clear every visual in the module and ensure the Item Description redraws on selection changes. |
| Conditional objects never change as expected | Compare Operator, Compare Value, and source type | Use a numeric or convertible Attribute and test both passing and failing values. |
| A color always uses Missing Color | Attribute type, integer or enum index, and Colors length | Supply an in-range integer or enum value and add a color for every supported index. |
Related pages
- Views and View Modules
- UI Designer Attribute View
- UI Designer Item Description
- Runtime Item Description
- Attributes and scope
- Define Attributes
- Common Attribute names and types
Customize and use the API
Create a custom module only when the shipped modules cannot present the required value. Inherit from AttributeViewModule, implement SetValue(AttributeInfo) for the visible state, and implement Clear() for every state that the module changes. AttributeInfo contains both the resolved Attribute and its originating ItemInfo, so a custom module can use Item context without making the Attribute View responsible for selection.
To supply a View directly, resolve the Attribute from the intended Item and pass both values together:
if (itemInfo.Item != null &&
itemInfo.Item.TryGetAttribute("Durability", out var attribute)) {
attributeView.SetValue((attribute, itemInfo));
} else {
attributeView.Clear();
}
Call Refresh() when the current Attribute object changed and the same View should redraw. Call Clear() before reusing the View for an empty or unrelated value. These calls only update presentation; Attribute persistence, saving, and network synchronization remain the responsibility of their owning systems.
Released Version 1’s Show Hide Attribute View writes the evaluated Attribute name and numeric value to the Console each time it updates. Account for that built-in behavior before using it in a frequently refreshed list, or replace it with a project-owned module when the logging is unsuitable.