I wonder if there is a way to display text for damage or durability in percentages for a certain item to show over icon in the inventory. It would show the text label in the middle or bottom of button slot in inventory UI. Something like 100%, 70%, 50% that I'll control through the action list. So the idea is that the player picks up, for example, a hammer in the inventory that is, say, 50% damaged, and when he uses it on the hotspot, with each use, the percentage will decrease by 20 or 10 until it reaches zero. I thought that this would be easiest with the same icons of different graphics of 100, 70, 50, etc. that I would change in the inventory, but it would be too crowded if I used them on some other items in the inventory. I assume that it can be done through an integer variable, inventory element menu label.. what would be the best approach here? Any ideas? I am using AC prefab Unity UI for inventory.
Unity 2022.3.8f1 and AC v,1.81.5
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
While you could "hack" it by using dedicated variables for certain items, the clean way is to rely on Inventory Properties.
If you go to the Inventory Manager's Properties tab, you can create a new Integer property named e.g. Durability. Your item(s) can each then be assigned a unique Durability value.
To have only certain items have such a value, you can create a pair of Categories (the first being the default) and then limit the Property to only items in the second.
As part of the Hotspot Interaction, you can then run the Inventory: Property to Variable" Action to temporarily transfer the given item's Durability to a Global Integer, modify it with **Variable: Set, and then run another Inventory: Property to Variable to transfer it back.
To display the value in your Menu, use a Unity UI-based Inventory Menu, and then attach a Text component to a GameObject that will show it. Then add this script and configure its Inspector, which will look up the Item in the slot you provide and put its value in the Text box:
Thanks Chris I'll try this method