Forum rules - please read before posting.

Getting the current Container reference from a Container menu

Yo!

Is there a way to get the current container reference from within a script attached to a Container menu?

I need to change the responses to the user clicking on container items depending on the type of container the items are in. I have a script on the Container menu, but I can't seem to find an obvious reference to the current container.

Any ideas?

Olly

Comments

  • If the Menu just shows whichever Container is currently "active", then you can read this independently of the Menu with:

    AC.KickStarter.playerInput.activeContainer
    

    If you're mapping the InventoryBox to a specific Container, however, you can read the InventoryBox element's OverrideContainer property:

    var canvas = GetComponent<Canvas>();
    var menu = KickStarter.playerMenus.GetMenuWithCanvas(canvas);
    var inventoryBox = menu.GetElementWithGameObject(itemSlot) as MenuInventoryBox;
    var container = inventoryBox.OverrideContainer;
    

    Where itemSlot is a GameObject reference to any Button linked to the InventoryBox element in the Menu Manager.

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.