Item Action

MrWilson

Member
I am trying to set up the item actions for assigning items to the hot bar. But when i do i get this error. I'm not sure if i set this up correctly.

1771202666645.png
1771202714098.png
 
Hey MrWilson!

When you have errors please to copy paste the entire error message stack as this helps us get the context of where the error comes from.

From just the screenshot I can't really tell what the issue is. Can you double check that you and an ItemUser on your inventory gameobject?
 
Hey MrWilson!

When you have errors please to copy paste the entire error message stack as this helps us get the context of where the error comes from.

From just the screenshot I can't really tell what the issue is. Can you double check that you and an ItemUser on your inventory gameobject?
It was a null reference, when clicking on the error it brought you to line 80 of the code. Which was referencing the item actions. But I think it was messing up on, when trying to assign the item the 2nd panel never came up. Whe looking at the demo it had 2 panels the first one, for right clicking and hitting assign and the 2nd one for choosing which box to assign it too
 
Hey MrWilson!

When you have errors please to copy paste the entire error message stack as this helps us get the context of where the error comes from.

From just the screenshot I can't really tell what the issue is. Can you double check that you and an ItemUser on your inventory gameobject?
1771464704376.png
 
Considering the error line. The issue is that either m_AsyncFuncActionPanel is null

m_AsyncFuncActionPanel is created a runtime from a prefab. When a prefab is not assigned it should be logging a warning. I can't quite see it from your screenshot but I'm guessing it's the warning just above your error.
Reading warnings in the console is important to get details about things that are not setup properly.

So in your AssignHotbarItemAction in the inspector Make sure to assign a prefab for the m_AsyncFuncActionPanelPrefab field.
 
Considering the error line. The issue is that either m_AsyncFuncActionPanel is null

m_AsyncFuncActionPanel is created a runtime from a prefab. When a prefab is not assigned it should be logging a warning. I can't quite see it from your screenshot but I'm guessing it's the warning just above your error.
Reading warnings in the console is important to get details about things that are not setup properly.

So in your AssignHotbarItemAction in the inspector Make sure to assign a prefab for the m_AsyncFuncActionPanelPrefab field.
This got it working, but when i go to use such item this warning pops up. Also is their away to turn off item actions for a consumable for the hot bar but still be able to use the item?
1771992551228.png
 
I'm not sure what the warning is pointing out.
Either you have specified an Inventory that has not ItemCollection, or the itemCollection specified was not found.
Check your MoveItemToEquippable item action to ensure the itemCollection you specified do exist in your Inventory.

As for your second question
> Also is their away to turn off item actions for a consumable for the hot bar but still be able to use the item?

Yes, on your hotbar you can specify can remove the ItemActionPanel and instead have it call the first valid action is can find in the itemAction group.

I usually have different item action group for the InventoryGrid and the hotbar, this way you have more control.

Another option in case you want the ItemActionPanel but also a shortcut button that triggers an action you can add a component for that.
ItemViewSlotContainerItemActionHandler
ItemViewSlotContainerIndexedActionsHandler
ItemViewSlotContainerNamedItemActionHandler

Check these out
 
Back
Top