Forum rules - please read before posting.

Unity UI Container Menu Not Working in Builds

More Unity UI menu woes. I replaced my Container menu with a Unity UI version but for some reason it does not work properly in builds. I can put one item in the container, then can only ever select that item. Once I return that item to the inventory, it is permanently selected, instead of deselecting after returning to inventory grid.
It works fine in Editor.

Unity 2018.4.3
AC 1.77.4

Comments

  • How are your Menus navigated, and are you using Input System or Input Manager?

    Are you making use of a custom Event System?

    The difference you describe only affects the Inventory menu - with the item remaining selected after placing it back there. Is there a difference in behaviour with the Container menu itself?

  • Sorry, I forgot to mention I'm using direct navigation.

    However, I realise now it is not related to Unity UI at all - I reverted to an AC menu and the issue is still present. The culprit is actually the "Global Container" Don'tDestroyMe script that is active in the very first scene of the game and persists throughout all scenes (as intended). It is somehow blocking / breaking the container menu - even if it is not being used.

    Here is how I use it.
    After the first scene containing the Don'tDestroyMe container loads, it then loads the next scene, the main menu.

    From the main menu you can choose to start a game with either linked containers or not linked ("built-in" AC container behaviour).

    Problem is, even if you choose to use non-linked containers, therefore not using the Don'tDestroyMe script at all, it still messes up the container functionality (it seems that you can re-order items in the container grid properly, but not in the inventory grid. If you bring an item from the container to the inventory, it remains selected until you return it to the container grid, and no other items in the inventory can be selected).

    If I bypass the scene with the Don'tDestroyMe container, then everything works as it should (though obviously you can't use the linked containers).

  • The wiki page's DontDestroyMe script merely causes an object to survive scene changes. Changes in the way your menus work will be down to additional scripts - I'm presuming you have such attached to this object?

    If you want to have a given option in the main menu prevent this from working, you can either incorporate that behaviour into the script (e.g. the menu button sets a Global Boolean variable to True, and the script checks for this), or you remove this object if not needed (e.g. the menu button deletes the object, either through script, or with the Object: Add or remove Action).

  • The only additional script on the container is the "Limit Items From Container" script, which I have on all containers to enforce the limited inventory gameplay in my game. I have this component on all containers in my game and it works perfectly fine, except for this "global" one. I could be wrong, but I can't see that being the cause of the issue, as the actual container itself is just the same as any other really.

    When opening a container in my game, a variable is checked to see which mode the player is on. If on linked containers mode, it opens the "Don'tDestroy" container. If on unlinked, it opens the regular "local" container. Just as simple as that.
    But regardless of which mode the player is on, the functionality of the container system does not work if the Don'tDestroy / Global container is present in the scene, for some odd reason.

    Only one item / slot in the inventory grid is usable, and if that item is not placed in the container it remains selected. It is so strange.

    btw I checked and, despite what I said in my opening post, this issue is actually present in editor as well, so at least I don't need to make a build every time I need to test it.

  • But regardless of which mode the player is on, the functionality of the container system does not work if the Don'tDestroy / Global container is present in the scene, for some odd reason.

    As in, if you're in "unlinked" mode, and you manually disable the Global container in the Hierarchy, it then works?

    I can't see how that would be the case without the contribution of custom scripts.

    Have you adaped the LimitItemsFromContainer script to work with the specific Container it's attached to? As it is on the wiki, the menu/element names are hard coded, meaning multiple attachments in the scene will cause them to compound one another. So as to rule out it being a factor, temporarily comment out the body of its main function (OnMenuElementClick).

  • edited October 2023

    As in, if you're in "unlinked" mode, and you manually disable the Global container in the Hierarchy, it then works?

    Yes that's right. The other way around does not work though, as in, if I disable the local container, the Global container still doesn't work.

    I have not edited the script at all, apart from altering the default maxItems int.

    Sorry I'm not quite sure which lines to comment out here. I tried commenting out from line 10 all the way to 46, though this seemed to have no effect that I noticed.

  • The wiki script shouldn't be placed multiple times in the scene - it's not unique to any specific Container, only a specific Menu.

    Make sure to only have one instance of the script be present in the scene - you can attach it to the ContainerUI if your Container menu uses a Unity UI prefab.

    If disabling the Global Container fixes it, share screenshots or both it and any scripts attached.

  • the menu/element names are hard coded, meaning multiple attachments in the scene will cause them to compound one another.

    The wiki script shouldn't be placed multiple times in the scene - it's not unique to any specific Container, only a specific Menu.

    Make sure to only have one instance of the script be present in the scene

    Ah, this was it after all. I removed the LimitItemsFromContainer script from the "Global" container and it all seems to be working as intended. It still limits what the player can take as the script is already in the scene.

    I think I initially misunderstood that script, I thought it meant limit items from this specific container, that's why I put the component on all containers. They were not affected before as there was only one container in each scene.

    Thanks for the help Chris

  • edited October 2023

    Deleted - issue solved

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.