Store equipment bonuses, damage and durability in Item attributes, then read them from the gameplay system that owns the effect. UIS resolves attributes, sums numeric values and binds individual values to component properties; the project defines its final character formula.

Choose data ownership

Value Owner
Shared Iron Sword Attack 12 / Fire Wand Attack 18 Weapon Item Definition attribute.
One weapon’s changing Durability Item attribute on a mutable, unique category.
Character base attack Character/combat system.
Final attack, buffs, caps and modifier order One project-owned calculation shared by UI and gameplay.

Use exact case-sensitive attribute names and compatible types.

A character with base Attack 5 recomputes final Attack as 17 with Iron Sword's shared Attack 12, or 23 after swapping to Fire Wand's Attack 18; each weapon's Durability stays on its own Item.

Configure the data and consumer

  1. In Main Manager > Item Categories > Weapon, declare integer Attack under Attributes > Item Definition and integer Durability under Attributes > Item. Enable Mutable and Unique for independent weapon state.
  2. In Item Definitions, set Iron Sword/Fire Wand Attack to Override values 12/18, and choose starting Default Item Durability.
  3. Configure an equipment ItemSlotCollection, normally Equipment, Purpose: Equipped. Point Equipper > Inventory and Equipment Item Collection ID there; its default name/purpose is Equipped, so change the name for Equipment.
  4. Choose a consumer:
Outcome Route and contract
Character total Collection/Equipper sum helpers; recalculate from base after content changes.
Weapon component value Item Binding beside Item Object; compatible public property.
Selected Item display Attribute Item View / Int Attribute Item View.
Equip comparison Integer Equipper preview helpers, or project float/custom preview.
Healing, damage or timed effects Custom Item Action/Item Object Behaviour calling the gameplay system.

Feature scene 14 Get Set Attribute Stat (With Code) and GetSetAttributeExample demonstrate the data operations.

Character totals and formulas

For this example, recompute final attack = base attack + Equipment Attack sum after equip/unequip. Use EventNames.c_Equipper_OnChange or the collection’s OnItemCollectionUpdate. For stats that change while equipped, also react to Item.OnItemAttributeChange or recalculate immediately in the modifying action. Recomputing avoids accumulating rounding drift through repeated additions/subtractions.

Use Inherit, Override or Modify within the Item data hierarchy. Modify supports int, float and string; a child sword can use <Inherited> + 2. Keep character state, slot weights, caps, damage types and buff ordering in gameplay code.

Bind or display one Item

Add Item Object and Item Binding to the prefab, assign Database, choose Item Category: Weapon, then bind Attack under Item Definition Attributes to a matching public int property such as Damage. Binding follows c_ItemObject_OnItemChanged, checks category membership and connects attribute/property access; use a character calculation for multiple Items.

Attribute Item View exposes Attribute Name, Attribute Value Text, Default Text Value and Disable On Clear. Int Attribute Item View expects an integer and clears missing data to 0. These show the selected Item, not final character attack. DemoCompareAttributeView is a sample comparison; adapt project UI for floats or custom formulas.

Verify and restore

Equip Iron Sword: final attack should be base plus 12. Swap to Fire Wand: use 18. Verify the bound weapon property and selected Item UI independently. Change one weapon’s Durability without changing another. Save/load explicit Item overrides, requery equipment and recalculate derived totals.

Save rollback-sensitive values as explicit Item overrides before the checkpoint, and test inherited/override starting states separately. Inventory/manager Item savers preserve included Item state; derived totals, buffs and component-only values need recalculation or a gameplay saver.

Troubleshooting

Symptom Check and fix
Zero/stale total Match Equipment ID, initialized collection, exact Attack name/type and content/attribute-change triggers.
Stack contributes the wrong amount Choose once-per-stack or perAmount: true explicitly.
Fractions disappear Use float sums and a custom float preview.
Binding target absent or mismatched Expose a matching public property and select a category containing the Item.
Weapons share state or fail to restore Use mutable/unique Item attributes, explicit saved overrides and Item-saver coverage.

Developer reference

Equipment updates

Register/unregister on the Equipper instance with the same callback:

using UnityEngine;
using System;
using System.Collections.Generic;
using Opsive.Shared.Utility;
using Opsive.UltimateInventorySystem.Core;
using Opsive.UltimateInventorySystem.Core.AttributeSystem;
using Opsive.UltimateInventorySystem.Core.DataStructures;
using Opsive.UltimateInventorySystem.Core.InventoryCollections;
using UnityEngine;
using Opsive.UltimateInventorySystem.Equipping;
using EventHandler = Opsive.Shared.Events.EventHandler;
using Opsive.UltimateInventorySystem.Core;
public class CharacterAttack : MonoBehaviour
{
    [SerializeField] private Equipper m_Equipper;
    [SerializeField] private int m_BaseAttack = 5;

    public int Attack { get; private set; }

    private void OnEnable()
    {
        if (m_Equipper == null) { return; }

        EventHandler.RegisterEvent(
            m_Equipper,
            EventNames.c_Equipper_OnChange,
            Recalculate);

        Recalculate();
    }

    private void OnDisable()
    {
        if (m_Equipper == null) { return; }

        EventHandler.UnregisterEvent(
            m_Equipper,
            EventNames.c_Equipper_OnChange,
            Recalculate);
    }

    private void Recalculate()
    {
        Attack = m_BaseAttack + m_Equipper.GetEquipmentStatInt("Attack");
    }
}

ItemCollection.GetIntSum/GetFloatSum count each stack once. Numeric helpers accept resolved int/float values; missing or other types contribute nothing. Integer sums/previews cast float totals. IEquipper exposes integer methods; concrete EquipperBase also exposes GetEquipmentStatFloat.

Stack versus unit sums

Use AttributeUtility or Inventory overloads with perAmount: true for each unit:

var equipment = inventory.GetItemCollection("Equipment");

var oncePerStack = equipment.GetFloatSum("Attack");

var oncePerUnit = AttributeUtility.GetFloatSum(
    "Attack",
    equipment.GetAllItemStacks(),
    perAmount: true);

In-place attribute changes

Subscribe on entry to the relevant equipment slot and unsubscribe on departure:

private void TrackItem(Item item)
{
    item.OnItemAttributeChange += HandleItemAttributeChanged;
}

private void StopTrackingItem(Item item)
{
    item.OnItemAttributeChange -= HandleItemAttributeChanged;
}

private void HandleItemAttributeChanged(AttributeBase attribute)
{
    if (attribute.Name == "Attack") {
        Recalculate();
    }
}

AttributeBase.OnAttributeChanged can observe one attribute; a one-off modifying action can recalculate directly instead.

Related: Defining Attributes, Attributes, Attribute editor, Equipping, Item Binding, Skills, Item Views, Save System.