Forum rules - please read before posting.

Inventory item selection stopped working with custom script [AC 1.74.0-2]

edited September 2021 in Technical Q&A

Hi, Chris!

After installing the new AC version I've encountered a strange bug with choosing items from the inventory menu. I've installed AC 1.74.0, 1.74.1, 1.74.2 - it's reproduced in all of them.

My GUI is drawn for 1920x1080 resolution and I use "Absolute pixels" mode for making AC menus. I have my custom modification at the MenuSystem.cs file for resizing all these menus for different monitor resolutions, it is added at the end of the OnMenuEnable method in the MenuSystem.cs file (OriginalSize and other variables are added and set at corresponding classes):

            if (_menu.title == "Hotspot") // No need to resize Hotspot menus
                return;

            var screenWidth = KickStarter.mainCamera.GetPlayableScreenArea(false).width;
            var screenHeight = KickStarter.mainCamera.GetPlayableScreenArea(false).height;
            var coef = System.Math.Min(screenWidth / 1920, screenHeight / 1080);
            _menu.manualSize = _menu.OriginalSize * coef;
            _menu.Recalculate();

            foreach (var elem in _menu.elements)
            {
                elem.fontScaleFactor = elem.OriginalFontScaleFactor * coef;
                elem.SetSize(elem.OriginalSize * coef);
                elem.SetPosition(elem.OriginalPosition * coef);
                elem.RecalculateSize(MenuSource.AdventureCreator);
            }

            _menu.Recalculate();

And this modification worked fine until the latest update. Now, if this code is present at the OnMenuEnable method, I can't choose an item from the Inventory menu, except for clicking at some very special points of the item (I don't get what's so special about them). Almost all of this gif I was clicking fiercely, but only a couple of clicks worked out to choose an item:

If I remove this code, then items are being selected correctly all the time:

This code works without exceptions, there're no errors at the console log too.

Could you please help me correct this issue? What was changed in the new version of AC that could influence this behaviour? Maybe I should modify my menu resizing code somehow?

Thank you very much!

Comments

  • I have my custom modification at the MenuSystem.cs file

    You don't need to modify MenuSystem to update your Menu's appearance. Your code can go in a hook to the OnMenuTurnOn event in a separate script:

    private void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
    private void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
    private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
    {
        // Custom menu handling here
    }
    

    And this modification worked fine until the latest update

    If you're including all of v1.74 in this, what was the last version that didn't have this issue?

    I can't choose an item from the Inventory menu, except for clicking at some very special points of the item

    The clickable area of your menu should match its appearance. Check that there aren't any other Menus that could prevent clicks aren't involved - try resizing just your Inventory menu by itself.

    I'd recommend you switch to Unity UI for your menu rendering, though. Coupled with AC's "Auto Correct UI Dimensions" component, it's the best way to handle different resolutions in a game with a fixed target aspect ratio.

  • edited September 2021

    Thank you, Chris!

    If you're including all of v1.74 in this, what was the last version that didn't have this issue?

    1.73.8 version was fine.

    Check that there aren't any other Menus that could prevent clicks aren't involved

    No, there are no other menus that would be interfering with the Inventory menu.

    try resizing just your Inventory menu by itself.

    Tried it, but the problem, unfortunately, remains.

    I'd recommend you switch to Unity UI for your menu rendering

    To be honest, I don't like the Unity menu system very much =). And I really like AC menus!

    I was wrong thinking the reason was my custom script (I was testing at the "Mollusc" item and it seemed there was a difference with and without my script). But now I've rejected all the changes, then re-imported AC 1.74.2 - now it's vanilla without any of my scripts and modifications - and I still cannot select inventory item (the first one, "Jelly Fish").

    All this time I'm clicking:

  • I would need to see your Settings Manager, Inventory menu's properties, InventoryBox element properties, and the Jellyfish item's properties, in that case.

  • Interface and Inventory settings:

    Inventory menu properties:

    InventoryBox properties:

    Jelly Fish item properties:

  • No, there are no other menus that would be interfering with the Inventory menu.

    Are you absolutely sure? I ask this because I wasted way too much time troubleshooting my own menu issues, believing no other menus were interfering, but it turned out that an invisible part of a different menu was indeed sitting on top of an area that used to be interactive (a recent AC update changed the way menus interact).

    Not saying you are wrong, just suggesting that you to go through your menus one by one carefully if you haven't done that yet. It'd have saved me a lot of time if I'd heeded my own advice, lol.

  • @Rairun no worries at all! Thanks for your help, I didn't know the invisible menus (or their parts) could interfere, and definitely check it!

  • edited September 2021

    The item you're showing has no Standard interactions defined, and "Select item if unhandled?" is unchecked in your Settings Manager. Check this option to have the item be selectable.

  • @ChrisIceBox Thank you very much, I'll check it too!

  • Looks like Chris and Rairun were right - it's the menu to blame!

    I've got a special menu with closed shell, when user hovers it with mouse, an ActionList for turning on is being executed and it shows my Inventory Menu and the closed shell menu is overlapped by the Inventory:

    At AC version up to 1.73.8 it worked fine - I checked it again. But at 1.74.* it isn't - looks like even the invisible menu is messing with the visible one (yet the item was highlighted - so this behavior still seems to me kinda strange).

    I fixed this issue by locking the closed shell menu when showing the Inventory menu and unlocking it when Inventory menu is turned off.

    Chris, Rairun, thanks a lot for your help!

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.