Inventory Window UGUI
🎒 InventoryWindowUGUI Class
Namespace:
Esper.Inventool.UI.UGUI
Access:public
Type:class
Inherits:DraggableWindowUGUI
📦 Fields
protected
itemStackElementPrefab
ItemStackElementUGUI
Item stack element prefab placed over slots.
protected
inventorySlotPrefab
InventorySlotUGUI
Empty inventory slot prefab.
protected
inventoryFilterPrefab
InventoryFilterUGUI
Inventory filter prefab.
protected
currencyElementPrefab
CurrencyElementUGUI
Currency display element prefab.
protected
closeButton
Button
Close button.
protected
pageLeftButton
Button
Inventory previous page button.
protected
pageRightButton
Button
Inventory next page button.
protected
inventoryTitleLabel
TextMeshProUGUI
Inventory title element.
protected
weightLabel
TextMeshProUGUI
Inventory weight amount label.
protected
pagesLabel
TextMeshProUGUI
Inventory pages label.
protected
filterTitleLabel
TextMeshProUGUI
Inventory filter title label.
protected
weightArea
GameObject
Inventory weight area.
protected
currenciesContainer
RectTransform
Container for currency UI elements.
protected
inventoryArea
RectTransform
Inventory area.
protected
gridLayoutGroup
GridLayoutGroup
Grid layout for inventory slots.
protected
inventoryContentFitter
ContentSizeFitter
Inventory content size fitter.
protected
filterScroll
ScrollRect
Inventory filter scroll.
protected
inventoryScroll
ScrollRect
Inventory scroll rect.
protected
inventoryCanvasGroup
CanvasGroup
Canvas group used during reload.
protected
pagesArea
RectTransform
Area for pagination text and buttons.
protected
inventoryScrollbar
Scrollbar
Inventory scrollbar.
protected
currencyElements
List<CurrencyElementUGUI>
Loaded currency elements.
protected
inventoryFilters
List<InventoryFilterUGUI>
Inventory filters.
protected
selectedInventoryFilter
InventoryFilterUGUI
Currently selected filter.
protected
loadedInventorySlots
List<InventorySlotUGUI>
All loaded inventory slot elements.
protected
loadedItemElements
Dictionary<ItemStack, ItemStackElementUGUI>
Loaded item UI elements keyed by ItemStack.
protected
inventoryRequiresReload
bool
True if inventory requires reload.
protected
originalInventoryAreaHeight
float
Original height of the inventory area.
public
Loaded
bool
True if UI elements have been loaded (!firstOpen
).
public static
Instance
InventoryWindowUGUI
The active instance.
🔍 Properties
public
Loaded
bool
True if all UI elements have been loaded.
public static
Instance
InventoryWindowUGUI
The active instance.
🧰 Methods
protected override
Awake()
void
Singleton initialization, register buttons and event listeners, set current page, localize UI.
protected override
Start()
void
Reload currencies, filters, weight UI, pages text; cache original area height; hide content.
protected virtual
HandleItemDismantled(ItemStack itemStack, List<ItemStack> dismantleResult)
void
Reloads current inventory page after dismantle.
protected virtual
HandleItemUsed(ItemStack itemStack)
void
Reloads current inventory page after use.
protected virtual
HandleCurrencyChanged(Currency currency)
void
Updates currency texts.
protected virtual
HandleItemsUpdated()
void
Reloads current inventory page and updates currencies.
protected virtual
HandleItemDropped(ItemStack itemStack)
void
Reloads current inventory page after drop.
protected virtual
HandleMerchantError(Merchant.MerchantError error, string message)
void
Shows localized confirm prompt for merchant errors.
public
LocalizeElements()
void
Localizes UI labels if localization enabled.
public virtual
Toggle()
void
Toggles window open/close state.
protected virtual
HandleInitialOpen()
void
Starts first-open initialization coroutine when needed.
private
LateReload()
IEnumerator
Deferred initialization: select default filter, remove filters, start reload coroutine.
private
ReloadInventoryCoroutine()
IEnumerator
Rebuilds layout (layout rebuilds, reload slots, reload page) and fades canvas group.
public override
Open()
void
Opens window, performs initial open, triggers reload if required and sets active.
public virtual
IsPointInsideInventory(Vector2 point)
bool
Returns true if a screen point is inside the inventory scroll area.
protected
ShowOrHideWeightArea()
void
Shows or hides weight area based on settings.
protected
ReloadCurrencyElements()
void
Rebuilds currency UI elements from inventory currencies.
public
UpdateCurrenciesText()
void
Updates currency amount labels.
public
UpdateWeightText()
void
Updates weight text label.
public
UpdatePagesText()
void
Updates pages label text.
public
NextPage()
void
Advances to next inventory page and reloads.
public
PreviousPage()
void
Goes to previous inventory page and reloads.
public
ReloadCurrentInventoryPage()
void
Clears existing item elements, creates UI elements for items in current page, positions and rotates as needed, updates pages and weight.
public
GetItemElement(ItemStack itemStack)
ItemStackElementUGUI
Returns ItemStackElementUGUI for given ItemStack or null.
protected
ResetLoadedSlots()
void
Marks all loaded slots available visually.
protected
SetSlotInUse(InventorySlotUGUI slot)
void
Marks a slot visually as in‑use.
protected
SetSlotAvailable(InventorySlotUGUI slot)
void
Marks a slot visually as available.
protected
CreateItemStackElement(ItemStack itemStack)
ItemStackElementUGUI
Instantiates and sizes an ItemStackElementUGUI for given ItemStack.
protected virtual
ReloadInventorySlots()
void
Rebuilds slot grid according to inventory navigation mode, calculates cell size and instantiates slots.
protected virtual
ReloadInventoryFilters()
void
Rebuilds filter list, wires buttons to set/remove filters and reload pages.
protected virtual
SelectInventoryFilter(InventoryFilterUGUI filter)
void
Selects a filter, deselects previous, updates filter title text (localized).
protected virtual
DeselectInventoryFilter()
void
Deselects current inventory filter.
Active Instance
You can get the active InventoryWindowUGUI
instance with InventoryWindowUGUI.Instance
. Ensure there's an instance of it in your scene before using this field.
Opening & Closing
Open
Call the Open
method when the player wants to open their inventory.
InventoryWindowUGUI.Instance.Open();
Close
Close
simply closes the window.
InventoryWindowUGUI.Instance.Close();
Toggle
Optionally, you can use Toggle
to open or close the window.
InventoryWindowUGUI.Instance.Toggle();
Last updated