Forum rules - please read before posting.

Menu: Appear on input key, disappear on input key AND mouseoff?

edited September 2014 in Technical Q&A
So, I have my inventory appear when I press the Tab key. It also disappears when I press the Tab key again.

Is there a good way to make it also disappear when the mouse leaves the menu?

I ask because I don't want the player to have to hit tab again after having chosen an inventory item to use on something on the scene, it's an extra redundant step I'd like to eliminate.

Comments

  • I suppose what you can do, and this gets into more complicated code, is check in the Update function of a script whether your cursor's coordinates are outside of the rectangle of the inventory menu, and when that is true turn off the menu (additionally maybe only if the cursor is holding an inv item). If you need more specific help with that let me know. There might be another way but I don't know it.
  • edited September 2014
    This is the right approach, but there's a few functions that you can use of AC's to make it easier:

    Say your menu's called "Inventory":

    Menu inventoryMenu = PlayerMenus.GetMenuWithName ("Inventory");
    PlayerInput playerInput = GameObject.FindWithTag (Tags.gameEngine).GetComponent ();

    if (inventoryMenu.GetRect ().Contains (playerInput.GetInvertedMouse ())
    {
      inventoryMenu.TurnOff (true);
    }

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.