Hover Details
Scripting with the InventoolHoverDetails class.
The InventoolHoverDetails
class is a mini pop-up window that displays item details.
Fields & Properties
document
The UI document.
UIDocument
protected
root
The root of the content.
VisualElement
protected
topBackgroundElement
The element used to display the top background.
VisualElement
protected
imageElement
The element used to display the item image.
VisualElement
protected
itemNameLabel
The label that displays the item name.
Label
protected
itemTypeLabel
The label that displays the item type.
Label
protected
descriptionScrollView
The scroll view that contains the description.
ScrollView
protected
descriptionLabel
The label that displays the description.
Label
protected
enchantmentScrollView
The scroll view that contains the enchantments label.
ScrollView
protected
enchantmentsLabel
The label that displays the enchantments.
Label
protected
weightArea
The element that contains weight content.
VisualElement
protected
weightLabel
The label that displays the item's weight.
Label
protected
currencyIconElement
The element that displays the currency icon.
VisualElement
protected
currencyLabel
The label that displays the currency amount.
Label
protected
appearanceDelay
The length of time the user must hover an item for the details to display.
float
public
autoScrollDelay
The automatic scrolling delay when the scroll view reaches the beginning or end.
float
protected
descriptionAutoScrollSpeed
The automatic scrolling speed of the description scroll view.
float
protected
enchantmentsAutoScrollSpeed
The automatic scrolling speed of the enchantments scroll view.
float
protected
autoScrollDescriptionToEnd
If the description auto scroll is currently scrolling to the end.
bool
protected
autoScrollEnchantmentsToEnd
If the enchantments auto scroll is currently scrolling to the end.
bool
protected
openAction
The open action.
Action
protected
transitionState
The current transition state.
TransitionState
protected
TargetElement
The element currently being targetted.
VisualElement
public
IsOpen
If the hover details is currently open.
bool
public
Active Instance
You can get the active InventoolHoverDetails
instance with InventoolHoverDetails.Instance
. Ensure there's an instance of it in your scene before using this field.
Open
Opening the hover details essentially requires a VisualElement
target. By default, Inventool has special UI elements that hold a reference to an item, which is used by the InventoolHoverDetails
class to both open at the location of the UI element and also display the item details. So, it's not as easy as just calling an Open
method.
Close
Customizations
If you're okay with when the InventoolHoverDetails
is opened, but not okay with the information displayed, you can customize it.
Step 1: Create a New Class
Create a new class that inherits from InventoolHoverDetails
. In your scene, replace the Hover Details component with the new one you created.
Step 2: Override Methods
Override the four Open methods as shown below. Each one opens the hover details for a different UI item element (each UI element has a reference to an item).
Step 3: Implement Your Customizations
In the code example below, we're going to customize the description displayed when an inventory item is hovered with a custom scriptable object.
Last updated