Forum rules - please read before posting.

Close button in dynamic inventory menu

Hello!

I have modified the inventory menu to appear when players click on a backpack in the lower left corner of the game screen and pan out (to the right) only to a length based on the number of items in the inventory. The maximum number of unique inventory items anyone would see at a given time throughout the game is 17, so I have set the inventory box element to reflect that max.

The trouble I'm having is that I cannot seem to get the close button (which should appear at the right/open end of the inventory slider) to end up in the correct position. If I add it as a close button in the inventory menu, it wants to sit way over off to the right (possibly because it's looking for 17 slots?), OR cuddled over to the far left (on top of the open backpack. Can somebody please help me figure out how to get that close button to slide out and stay in that far right position?

Here are my Inventory menu settings:

InventoryBox element settings:

CloseButton element settings:

Here is how I want it to behave - close button on the far right, exact position dependent on the number of items in inventory:

AC v1.77.3
Unity 2022.3.0f1

Thank you for any [very simple] help you can provide -

Ann

Comments

  • If you're using AC as the Menu's Source, you'll need to have set all the elements' Position properties to Aligned, and the InventoryBox element's When slot is empty property to Disable Object.

    These two changes will cause each element to be positioned so as to fit next to the element before it, and the InventoryBox element will shrink to fit based on the number of items it holds.

    For better control over the animation, you'll be better off using Unity UI to render the Menu - but that should get the fundamental behaviour.

  • Thank you so much! I got that part to work correctly, but now the issue is that the rounded rectangle distorts on the right (curved) end, particularly where there are only a few items in inventory.

    I understand how to create sprite slices, but since the sprite is appearing in a menu rather than in a scene, I don't know where or how to change the draw mode for it. Is that possible?

    I really, really appreciate all of your help - you are amazing! :smiley:

  • It's possible - but you need to switch over to Unity UI for your Menu's rendering. Unity's Image component can make use of sliced sprites - but the ImGUI system (which is the basis of AC rendering) cannot.

    The Manual's "Unity UI menus" chapter has details on how Unity UI and AC's Menu system work together. A tutorial on creating an Inventory menu with Unity UI can be found here.

  • I'll look into that then. Thank you ever so much for your time... and this amazing tool!

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.