Inventory Pro

Creating a new wrapper


When you want to extend the UI features such as showing more information or adding extra input functionality you can create a new wrapper. Basic information about the concept of wrappers can be found here.

When using Unity UI (uGUI) it's easiest to extend from InventoryUIItemWrapper there's also an abstract class InventoryUIItemWrapperBase that has no Unity UI dependencies and can be used to implement other UI systems such as NGUI.

For this example we'll assume you're using Unity UI (uGUI) and inherit from InventoryUIItemWrapper.

Writing some code

A simple example is shown below where an extra text field is added. This field gets the item's name as long as the wrapper is not empty.

Repaint is only called after the object changed, not every frame like Update().


public partial class InventoryUIItemWrapperLoot : InventoryUIItemWrapper
{
    public UnityEngine.UI.Text extraTextField;

    public override void Update()
    {
        base.Update();
    }

    public override void Repaint()
    {
        base.Repaint();

        if (item != null)
        {
            extraTextField.text = item.name;
        }
        else
        {
            extraTextField.text = "";
        }
    }
}