Thank you for always helping me.
1, Clear hotbar
2, Newly obtained items are automatically set
3, Set the specified items
We are prototyping three movements.
There are some aspects of "iteminfo" that I don't fully understand.
I can set specified items, but new items cannot be set automatically.
Would you please tell me?
Is it necessary to specify itemCollection?
1, Clear hotbar
2, Newly obtained items are automatically set
3, Set the specified items
We are prototyping three movements.
There are some aspects of "iteminfo" that I don't fully understand.
I can set specified items, but new items cannot be set automatically.
Would you please tell me?
Is it necessary to specify itemCollection?
public void ItemHotBarAutoSet()
{
GameObject m_Player = GameObject.FindWithTag("Player");
Inventory myinventory = m_Player.GetComponent<Inventory>(); // Player
ItemCollection itemCollection = myinventory.GetItemCollection("Recovery"); // 回復フォルダから検索
var result = itemCollection.GetItemInfo(InventorySystemManager.GetItemDefinition("ハート"));
if (result.HasValue == false) { return; }
var ItemInfo = result.Value;
var Recovery = InventorySystemManager.GetItemCategory("回復アイテム");
var isTool = Recovery.InherentlyContains(ItemInfo.Item);
Debug.Log("isTool "+isTool+"/"+ ItemInfo.Item);
if (isTool)
{
// Add to Hotbar.
uint panelManagerID = 1;
var panelName = "Item Hotbar";
var hotbar = InventorySystemManager.GetItemViewSlotContainer<ItemHotbar>(panelManagerID, panelName);
Debug.Log("hotbar " + hotbar);
for (int i = 0; i < hotbar.SlotCount; i++)
{
if (hotbar.GetItemAt(i).Item != null) { continue; }
hotbar.AddItem(ItemInfo, i);
break;
}
}
}