Hi, I've been looking for the right way to implement this. Basically, I have a list of inventory items with a property called "Time Collected" and I want to display it in the container UI.
I've setup my container to have the textBox and made a custom script to load it but I can't make it work so I am now heading to the forums to pray to the AC God.
Here's how my inventory layout looks like:
https://imgur.com/a/C3Yk29r
So I want my inventory items to display the time directly on their lower right.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Also, I believe this should be implemented built-in because I imagine this should be a pretty common use-case (unless there is a built-in way and I'm just dumb to see it). So maybe in the future? 🤞
A custom script is necessary - you'd need to attach it to each UI Button in your prefab.
With the latest AC release, it's possible to extract the Inventory Item Instance from the Button it's associated with without need for additional variables.
This is brute-forced in an Update loop, so you'd probably want to move to e.g. OnEnable, but this should do it:
Thank you for your lightning fast response. I might be doing something wrong here. The slot index is always -1. To confirm, this is supposed to be applied to the btnSlots inside the Container Grid right?
Here is an image of the hierarchy: https://imgur.com/rEJiUiN
The highlighted part is where this code is placed:
I managed to fix it by changing line 676 in the MenuInventoryBox code from:
to: