Forum rules - please read before posting.

Get an invItem from a UGUI focused slot?

edited December 2016 in Technical Q&A
Hi, again. Basically, working in the VR integration (SteamVR/VRTK) I've made this simple but effective way to interact with the inventory UI. The selection of UI slots is rather simple, I put any shape of trigger collider over the slots and define a menu element for the event system to focus on, that way the player can physically select slots in the inventory using the controller (or any menu, really, I have it so you can define the trigger as an inventory slot, regular element or a shift button for invbox or journals). Along with this I made a system to store and take out items from the inventory, also using triggers as Store Zones or Extraction zones, that way people can put the zones anywhere (inside a bag, on a UI slot, etc). Now storing was easy, but extracting items was more annoying. 

I first tried to use the runtime inventory's highlighteditem but that didn't work even though the slots were focused by the event system, so I tried selectedItem and I simulated a button press but it also didn't work, I kept getting null all the time for the invItem, even though I was sure I was highlighting or selecting the slot (when I simulated the clicks I always got the actual item icons in the center of the screen so I'm sure they were getting pressed). I'm pretty sure I tried with the inventory boxes methods too, but at the end I had to get my "UI Selectors" (triggers) to define the slot they belonged to, to use: 

invBox.GetItem(_nearestUiSlot.InventorySlotId);

Anyway, I'm not truly satisfied with this method, as it' not as automatic as I wish it was. The user has to define the right slot Id for each trigger for it to work, and I need to trycatch for any situations where the selected slot has nothing in it. So, do you have any idea why the other methods didn't work?

Anyway, as usual, any advice will be greatly appreciated (and sorry for the sudden bombardment of questions).

Comments

  • edited December 2016
    selectedItem refers to the currently-held inventory item, i.e. the one that the player is then "holding" once clicking on an item in the menu, not just hovering-over with the mouse.

    highlightedItem is a special variable used to manually highlight items using the Object: Highlight Action.

    In a normal AC Menu, it's hoverItem that's used to store the item that's currently being hovered-over by the mouse.  If that doesn't return what you need, I expect something within the MenuInventoryBox class have it, but I'll need to know more about how you're syncing it with the triggers.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.