Forum rules - please read before posting.

Inventory auto closing on item examine

Hello folks,

Currently, when the player examines (right clicks) an item in my inventory the inventory seems to auto-close and then the examine action list is run.

I want to change this so the inventory stays open while examines are happening.

It's been a while since I've touched the inventory, but is this do-able?

Thanks!

Comments

  • What's the menu's Appear type property set to? When it turns on/off will depend on that.

    When set to Manual, it should only turn off when explicitly told to do so, either through scripting or with the Menu: Change state Action.

  • @ChrisIceBox Pleasure to see your face again! It's currently set to "On Input Key". I'll put it to manual and try and script its activation. Thanks!

  • I think I figured out why it was closing initially; my right mouse button was also hooked up to inventory toggle in Unity's input manager, but also used for examining. So it makes perfect sense why the inventory was closing down on examine.

    The joys of relearning your own setup, haha!

  • @ChrisIceBox Is there anything I can check against which will say "the mouse cursor is currently mouse over'ing something in the inventory"?

  • edited June 2019

    Good to hear from you too, @Temmy!

    It's currently set to "On Input Key". I'll put it to manual and try and script its activation.

    One option would be to create an "Active Input" to handle the menu toggling, and then disable the active input while an item is being examined.

    Is there anything I can check against which will say "the mouse cursor is currently mouse over'ing something in the inventory"?

    The Menu class has two functions for this: IsPointInside and IsPointerOverSlot.

    They both require a Vector2 position to check for - this is typically the mouse position, but because OnGUI flips the y-coordinate you need pass:

    KickStarter.playerInput.GetInvertedMouse ()
    

    For more on how to access a Menu class through script, see the Manual's "Menu scripting" chapter.

  • edited July 2019

    Hi Chris,

    IsPointerOverSlot is sort of what I need, but, in this case it will say true for any slot of the InventoryBox element the mouse cursor is over. In my case, I only care about slots that are showing something in them.

    Also IsPointerOverSlot takes a specific slot int. If, for instance, I had three items in my inventory how would I sensibly check if three slots are filled?

    Interesting shout about the Active Input, I might give that a try instead.

    Thanks!

  • If IsPointerOverSlot returns true, then you can call MenuInventoryBox's GetItem function for the same slot number, which returns the item placed in that slot, i.e.:

    if (myMenu.IsPointerOverSlot (myInventoryBox, slotIndex, myMousePosition))
    {
        InvItem itemInSlot = myInventoryBox.GetItem (slotIndex);
    }
    
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.