Hi Brian
The Buttons are just for testing the navigation in the UI. In the end I want navigate trough the inventory with the gamepad/keyboard. At the highlighted item in want to can open a dropdownmenu to: drop, equip or inspect the item.
I spend many times, hours, to understand the new Input system. There are different concepts.
They looks logical. But knowhere I found a good explanation about, deep inough when it’s more complex. Now I know that I know nothing how the Input system really works.
I think I know the Input system good, but I have completely chaos inside my brain.
I have many many courses from GameDev.tv and I love them!!!
Is there a chapter where explane Input UI and PlayerInput with gamepad I didn’t found?
Update:
Ok Now I understand the Input System better. I need alway a first Button.
Back to the Inventory. I Updated the InventoryUI script.
private void Start()
{
Redraw();
AddButtonsInList();
}
private void Redraw()
{
foreach (Transform child in transform)
{
Destroy(child.gameObject);
}
for (int i = 0; i < playerInventory.GetSize(); i++)
{
var itemUI = Instantiate(InventoryItemPrefab, transform);
itemUI.Setup(playerInventory, i);
}
}
private void AddButtonsInList()
{
for (int i = 0; i < playerInventory.GetSize(); i++)
{
inventoryButtons.Add(new GameObject());
Debug.Log("Slot number " + i);
}
Debug.Log("First button " + inventoryButtons[0]);
}
public GameObject GetFirstSlot()
{
return inventoryButtons[0];
}
Then I Get the first Slot GameObject where I handle my UIs.
var eventSystem = EventSystem.current;
eventSystem.SetSelectedGameObject(inventoryUI.GetFirstSlot());
But it gives me this error:
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
And sorry I have still problem to paste the code in a good format here.
Greetings
Phaidon