Inventool Window

Scripting with the InventoolWindow class.

The InventoolWindow is the main in-game UI that the player can work with.

Fields & Properties

Name
Description
Type
Access

document

The window UI document.

UIDocument

public

selectedTabButton

The currently selected tab button.

Button

protected

currenciesContainer

Contains currency visual elements.

VisualElement

protected

currencyElements

Loaded currency elements.

List<CurrencyElement>

protected

inventoryFilters

A list of inventory filters.

List<InventoryFilter>

protected

selectedInventoryFilter

The currently selected filter.

InventoryFilter

protected

tabButtonContainer

The element that contains all tab buttons.

VisualElement

protected

inventoryTabButton

The inventory tab button.

Button

protected

craftingTabButton

The crafting tab button.

Button

protected

enchantingTabButton

The enchanting tab button.

Button

protected

keyItemsTabButton

The key items tab button.

Button

protected

inventoryTitle

The inventory title element.

VisualElement

protected

craftingTitle

The crafting title element.

VisualElement

protected

enchantingTitle

The enchanting title element.

VisualElement

protected

shopTitle

The shop title element.

VisualElement

protected

inventoryTab

The inventory tab.

VisualElement

protected

inventoryContent

The inventory content.

VisualElement

protected

slotContainer

The element that contains all equipment slots.

VisualElement

protected

craftingTab

The crafting tab.

VisualElement

protected

enchantingTab

The enchanting tab.

VisualElement

protected

keyItemsTab

The key items tab.

VisualElement

protected

shopTab

The shop tab.

VisualElement

protected

storageTab

The storage tab.

VisualElement

protected

activeTab

The currently active tab.

VisualElement

protected

characterViewerElement

The character viewer element.

CharacterViewerElement

protected

inventoryFilterScroll

The inventory filter scroll view.

ScrollView

protected

weightArea

The inventory weight area.

VisualElement

protected

weightLabel

The inventory weight amount label.

Label

protected

inventoryFilterTitleLabel

The inventory filter title label.

Label

protected

itemContent

The inventory item content.

VisualElement

protected

craftingContent

The crafting content.

VisualElement

protected

enchantingContent

The enchanting content.

VisualElement

protected

inventoryScroll

The inventory scroll view.

ScrollView

protected

pagesArea

The area for the pagination text and buttons.

VisualElement

protected

inventoryPagesLabel

The inventory pages label.

Label

protected

inventoryPageLeftButton

The inventory's previous page button.

Button

protected

inventoryPageRightButton

The inventory's next page button.

Button

protected

loadedInventorySlots

A list of all loaded inventory slots.

List<VisualElement>

protected

loadedItemElements

A list of all loaded item UI elements.

Dictionary<ItemStack, ItemStackElement>

protected

singleInventorySlotSize

The size of a single inventory slot.

float

protected

keyItemScroll

The scroll view containing all key items.

ScrollView

protected

keyItemContent

The visual element that contains all content elements of the selected key item.

VisualElement

protected

keyItemImage

The visual element used to display the selected key item's icon.

VisualElement

protected

keyItemNameLabel

The label used to display the selected key item's name.

Label

protected

keyItemSubtypeLabel

The label used to display the selected key item's subtype.

Label

protected

keyItemDescriptionLabel

The label used to display the selected key item's description.

Label

protected

selectedKeyItem

The currently selected key item.

KeyItemElement

protected

equipmentSlotElements

A list of all equipment slot elements.

List<EquipmentSlotElement>

protected

enchantmentSlotElements

A list of all enchantment slots.

List<ItemSlotElement>

protected

craftingSlotElements

A list of all crafting slots.

List<ItemSlotElement>

protected

enchantmentSlotLeft

Left enchantment slot.

ItemSlotElement

protected

enchantmentSlotRight

Right enchantment slot.

ItemSlotElement

protected

enchantmentCostIcon

Enchanting cost icon element.

VisualElement

protected

enchantmentCostLabel

Enchanting cost label.

Label

protected

enchantButton

The button that confirms the enchant.

Button

protected

craftScroll

The scroll view that contains a list of items to craft.

ScrollView

protected

craftListElement

The element that contains the items to craft.

VisualElement

protected

craftCostIcon

Crafting cost icon element.

VisualElement

protected

craftCostLabel

Crafting cost label.

Label

protected

craftButton

The button that confirms the craft.

Button

protected

craftResultSlot

The craft tab result item slot.

ItemSlotElement

protected

craftEmptyLabel

The label that is displayed when the craft list is empty.

Label

protected

keyItemsEmptyLabel

The label that is displayed when the key items list is empty.

Label

protected

closeButton

The close button.

Button

protected

crafter

Crafting logic handler.

Crafter

protected

activeShopkeeper

The shopkeeper currently being interacted with.

Shopkeeper

protected

activeEnchanter

The enchanter currently being interacted with.

Enchanter

protected

activeCraftsman

The craftsman currently being interacted with.

Craftsman

protected

shopFilterScroll

The shop filter scroll view.

ScrollView

protected

shopScroll

The shop scroll view.

ScrollView

protected

root

The root element.

VisualElement

protected

shopFilters

A list of shop filters.

List<InventoryFilter>

protected

selectedShopFilter

The currently selected shop filter.

InventoryFilter

protected

characterViewer

The active character viewer.

CharacterViewer

public

rotationResetButton

The button that resets the character viewer rotation.

Button

public

openedTab

The type of the currently opened tab.

Tab

public

useEnchantingCost

If the enchanting cost should be used. This is set to true if the window is opened for enchanting only.

bool

protected

useCraftingCost

If the crafting cost should be used. This is set to true if the window is opened for crafting only.

bool

protected

firstOpen

If this is the first time the window is being opened.

bool

protected

inTransition

If the window is currently in the open or close transition.

bool

protected

Loaded

If all UI elements have been loaded.

bool

public

IsOpen

If the window is currently open.

bool

public

OpenedForMerchant

If the window is currently open for a merchant or storage.

bool

public

Active Instance

You can get the active InventoolWindow instance with InventoolWindow.Instance. Ensure there's an instance of it in your scene before using this field.

Opening & Closing

Open

The InventoolWindow can be opened in multiple ways, each for a different purpose.

Opening For Player

Call the Open method when the player wants to open their inventory.

InventoolWindow.Instance.Open();

Opening For Merchant

You can open the window for the specific merchant by providing the merchant reference as a parameter.

InventoolWindow.Instance.Open(myMerchant);

Opening for Storage

You can open the window for a specific storage by providing the storage reference as a parameter.

InventoolWindow.Instance.Open(myStorage);

Close

Close closes the window if opened for the player. Use Exit to close the window when opened for a merchant. Optionally, you can use ForceClose to close the window whether it's opened for a merchant or not.

InventoolWindow.Instance.Close();

Toggle

Optionally, you can use Toggle to open or close the window.

InventoolWindow.Instance.Toggle();

Character View

Setting Custom Image

If you don't have a Character Viewer set up in your scene, a default image will be displayed in the equipment section. You can override this image with a custom one.

Step 1: Create a New Class

Create a class (name it whatever you'd like) and make it inherit from InventoolWindow.

using Esper.Inventool.UI;
using UnityEngine;

public class MyInventoolWindow: InventoolWindow
{

}

Step 2: Replace Component

Replace the InventoolWindow component in your scene with the new one you just created.

Step 3: Set Custom Image

Set the custom image. You can handle this however you'd like. Below is just an example of how it could be done.

using Esper.Inventool.UI;
using UnityEngine;

public class MyInventoolWindow: InventoolWindow
{
    // Set from the inspector
    // Sprite can work as well
    [SerializeField]
    private Texture2D texture;

    protected override void Start()
    {
        base.Start();
        characterViewerElement.style.backgroundImage = texture;     
        // characterViewerElement.style.backgroundImage = new StyleBackground(sprite);
    }
}

Reset Character View Rotation

If you have the Character Viewer set up, you can call ResetCharacterViewRotation to reset its view.

InventoolWindow.Instance.ResetCharacterViewRotation();

Other Customizations

Programmatic customizations of the UI can be a complex task. Not much information about this is included due to its complexity. If you'd like the InventoolWindow to do something in specific, consider reaching out. Also, check out the Future Plans—perhaps what you're looking for is already a planned feature!

Last updated