Introduction
This component handles refreshing the Inventory UI for individual ItemAmount information once clicked on a InventoryItemSlot.
Setting up
There is a prefab ItemAmountInfoPanel located in /prefabs/UI.
Setting up without the prefab otherwise is a little more complicated, as it would involve creating and linking all the visual UI elements. If you wanted to go ahead and do this, you can simply create the elements you need and assign them to this component. Only assigned fields are updated, so do not worry about leaving unnassigned fields on this component.
This component should be placed under a Canvas.
Settings
Item Name
The TextMeshProUGUI component to display the Item’s Name.
Item Icon
The Image component to display the Item’s Icon.
Description
The TextMeshProUGUI component to display the Item’s Description.
Count
The TextMeshProUGUI component to display the ItemAmount’s Amount.
Value
The TextMeshProUGUI component to display the Item’s Value of 1 unit.
Stack Size
The TextMeshProUGUI component to display the Item’s Stack Size.
Slider
The Slider component to select a range of ItemAmount to sell.
Sell Btn
The Button component to initiate the Sell function using the Slider’s value as the Amount to sell.
Sell Btn Text
The TextMeshProUGUI component to display the sell text.
Close Btn
The Button component to close this panel.
Scripting
/// <summary>
/// Refresh the Item Information Panel
/// </summary>
/// <param name="itemAmount">The Item Amount to display</param>
/// <param name="initSliderValue">Sets the slider current value to 0 if true</param>
public void RefreshItemPanel(ItemAmount itemAmount, bool initSliderValue = false)
/// <summary>
/// A variation of RefreshItemPanel where it can take in a InventoryItemSlot, this is used if using Consolidated in the Inventory Manager
/// </summary>
/// <param name="inventoryItemSlot">The InventoryItemSlot to use for the ItemAmount to display</param>
/// <param name="initSliderValue">Sets the slider current value to 0 if true</param>
public void RefreshItemPanel(InventoryItemSlot inventoryItemSlot, bool initSliderValue = false)
/// <summary>
/// A variation of RefreshItemPanel where it will update the currently selected InventoryItemSlot if there is one
/// </summary>
public void RefreshFromSelectedInventoryItemSlot()
/// <summary>
/// Sell part of the currently selected item based on the slider value
/// </summary>
public void SellItemAmount()
/// <summary>
/// Sell part of the given item based on the slider value
/// </summary>
/// <param name="itemAmount">The itemAmount item to sell</param>
public void SellItemAmount(ItemAmount itemAmount)
//If you wanted to manually sell an ItemAmount using your own logic,
//use InventoryManager > public void SellItemAmount(ItemAmount itemAmount)