Item
🧸 Item Class
Representation of an item. While it may seem like the Item class is the main class you'll be working with, it's actually not. Chances are, you'll be using the ItemStack
class far more. Basically, the Item
class is like an ID for an ItemStack
, and the ItemStack
class is what is the inventory stores. Click here to learn about item stacks.
Namespace:
Esper.Inventool.Items
Access:public
Type:class
Inherits:InventoolObject
📦 Fields
public
itemClass
ItemClass
The class of the item.
public
currencyPouch
CurrencyPouch
The currency gained when this item is obtained (only relevant if class = Currency).
public
icon
Sprite
The icon displayed in the inventory.
public
singleSlotIcon
Sprite
The icon displayed in a single-slot item slot.
public
hoverImage
Sprite
Image used for the hover details popup.
public
keyItemsImage
Sprite
Image used in the key item section.
public
inventoryBackgroundImage
Sprite
Background image in the inventory.
public
singleSlotBackgroundImage
Sprite
Background image in a single-slot item slot.
public
hoverBackgroundImage
Sprite
Background image in the hover details popup.
public
shopBackgroundImage
Sprite
Background image in the shop.
public
profile
StatProfile
The stat profile of this item.
public
enchantmentLimit
int
Hard limit on enchantments (only relevant if limit type = Individual).
public
displayName
string
The display name shown in-game.
public
localizedDisplayNameKey
string
The key of the localized display name string.
public
itemType
ItemType
The type of this item.
public
description
string
The description shown in-game.
public
localizedDescriptionKey
string
The key of the localized description string.
public
currencyIdentity
CurrencyIdentity
The currency identity used for costs.
public
buyingPrice
Currency
The price when purchasing from vendors.
public
sellingPrice
Currency
The price when selling to vendors.
public
overrideDropPrefab
GameObject
Overrides the default item drop prefab.
public
customObject
Object
A custom object for any purpose.
public
dismantleResult
List<ItemStack>
Items gained when dismantled.
public
enchantment
Enchantment
The enchantment this item provides when used to enchant another item.
public
size
Vector2Int
The amount of space (slots) this item takes in the inventory.
public
weight
float
The weight of the item. (Obsolete — use profile.weight
instead)
public
hideStats
bool
If stats should not be displayed when hovered.
public
dataset
Dataset
The dataset of this item.
🔍 Properties
public
SlotCount
int
The number of slots this item requires.
public
IsKeyItem
bool
If this is a key item.
public
Stackable
bool
If this item can be stacked.
public
LevelingEnabled
bool
If this item can level.
public
DurabilityEnabled
bool
If durability is enabled for this item.
public
DatabaseRecord
ItemRecord
The database record of this item.
public static
DirectoryPath
(Editor only)
string
The directory of items.
🧰 Methods
public
DeleteDatabaseRecord()
(Editor only)
void
Deletes the record of this object from the database.
public
UpdateDatabaseRecord()
(Editor only)
void
Updates the record of this object in the database.
public
GetEnchantmentLimit()
int
Gets the enchantment limit.
public
GetLocalizedDisplayName()
string
Gets the localized display name string.
public
GetInterpolatedDescription()
string
Gets the description with variable interpolation (localized if enabled).
public
GetSprite(SpriteType spriteType)
Sprite
Gets a specific item sprite, with fallbacks.
public
GetBackground(SpriteType spriteType)
Sprite
Gets a specific background sprite, with fallbacks.
public
CreateNewItemStack(int amount = 1)
ItemStack
Creates a new stack of this item.
public
SetData(Item item)
void
Sets this item’s data from another item.
public
GenerateDataset()
void
Generates the dataset with the dataset reference (editor only).
public static
Create()
Item
Creates a new instance of an item (editor only).
public
UpdateAssetName()
(Editor only)
void
Updates the name of the asset.
public override
Save()
void
Saves the item and updates its database record (editor only).
public static
GetFullPath(Item item)
(Editor only)
string
Gets the full path of an item.
public static
CreateCopy(Item original)
Item
Creates a copy of another item.
🧩 Nested Types
public enum SpriteType
public enum SpriteType
Inventory
The inventory sprite.
SingleSlot
Single slot sprite.
Hover
The on-hover sprite.
KeyItem
The key item sprite.
Shop
The shop sprite.
public enum ItemClass
public enum ItemClass
Normal
Represents a custom item. Treated as a normal item.
Currency
Represents a currency. Won’t appear in inventory; adds currency to player.
Creating Items
It's not at all recommended to create items at runtime, but it is possible. Items are scriptable objects which cannot be created as assets at runtime for later use. You would need to load your generated items on your own.
Item myItem = ScriptableObject.CreateInstance<Item>();
Item IDs must be unique. When creating items from the Items tab, unique IDs are set automatically. However, this is not done when creating items at runtime. You'd need to create your own method of ensuring IDs of generated items are unique.
Getting Items
Items created through the Items tab can be retrieved at runtime.
Get a Single Item
You can get an item by its ID or display name with the Inventool.GetItem
method.
Item myItem = Inventool.GetItem("My Item Name");
Get All Items
var items = Inventool.GetallItems();
Creating an Item Stack
You can create an Item Stack from an Item
with the CreateNewItemStack
method. This method accepts a integer which represents the stack amount. Note that if an item is not stackable, it will always create a stack of 1.
// Create an item stack of 10
ItemStack myItemStack = myItem.CreateNewItemStack(10);
Getting Icon/Background
You can get a specific item image or background with the GetSprite
and GetBackground
methods. These methods are generally good to use because they will fallback to an available sprite if the one requested was not set.
var sprite = myItem.GetSprite(spriteType);
var background = myItem.GetBackground(spriteType);
Interpolated Description
You can get the item description with text interpolation with the GetInterplatedDescription
method. This essentially helps display stats in item descriptions. Read more about this here.
string description = myItem.GetInterpolatedDescription();
Last updated