Forum rules - please read before posting.

Bug: When I have multiple same items with the hotspot position "On Hotspot"

Hello.
Adventure creators are a great asset! I feel that it can be used in the production of any game other than the typical adventure game.
While doing various tests for my game, I ran into an error that occurred under complex conditions.
The Unity version is 2019.4.7f1, the AC version is the latest 1.72.0, and the OS is Windows 10.

Overview:
When the hotspot position is "On Hotspot" and you have a lot of the same items, you will get an error if you mouse hover into the inventory after offsetting the element slot with the Shift Right button.

Reproduction procedure:
1. Unity menu-> Adventure Creator-> Getting started-> New Game wizard. Create a new 2D game.
2. Create an item in Inventory Manager. Check on "Can carry multiple?"
3. Create Hotspot2D and add Use interactions. Create an action list that adds the item to your inventory each time you click it.
4. Set Menu manager -> Hotspot -> Position to "On Hotspot".
5. Change Menu manager-> Inventory-> Source to "Unity Ui Prefab".
6. Play the game and get 14 or more of the same items until your inventory is full.
7. Press the Shift Right button in the inventory to Offset Slot.
8. You get an error when I hover the mouse over the Inventory Box.

Error log:
IndexOutOfRangeException: Index was outside the bounds of the array.
AC.MenuInventoryBox.GetRectTransform (System.Int32 _slot) (at Assets / AdventureCreator / Scripts / Menu / Menu classes / MenuInventoryBox.cs: 321)
AC.Menu.GetSlotCentre (AC.MenuElement _element, System.Int32 slot) (at Assets / AdventureCreator / Scripts / Menu / Menu classes / Menu.cs: 2787)
AC.PlayerMenus.UpdateMenuPosition (AC.Menu menu, UnityEngine.Vector2 invertedMouse, System.Boolean force) (at Assets / AdventureCreator / Scripts / Controls / PlayerMenus.cs: 867)
AC.PlayerMenus.UpdateMenu (AC.Menu menu, System.Int32 languageNumber, System.Boolean justPosition, System.Boolean updateElements) (at Assets / AdventureCreator / Scripts / Controls / PlayerMenus.cs: 992)
AC.PlayerMenus.UpdateAllMenusAgain () (at Assets / AdventureCreator / Scripts / Controls / PlayerMenus.cs: 2120)
AC.PlayerMenus.UpdateAllMenus () (at Assets / AdventureCreator / Scripts / Controls / PlayerMenus.cs: 2109)
AC.StateHandler.Update () (at Assets / AdventureCreator / Scripts / Game engine / StateHandler.cs: 232)

I haven't touched AC so much, so I haven't found the right fix.

Comments

  • Welcome to the community, @umiyuki.

    Thank you for the clear steps - I'll look into this presently.

    Are you getting this error when hovering over a specific slot in the InventoryBox, or any part of it?

  • Thank you for investigating this error.

    After offsetting the slots, an error will be displayed no matter which slot you hover.

  • Recreated - thanks.

    I shall issue a proper fix in the next update, but in the meantime you can at least prevent the errors from showing by opening MenuInventoryBox.cs and replacing line 319:

    if (uiSlots != null && uiSlots.Length > _slot)
    

    with:

    if (uiSlots != null && _slot >= 0 && uiSlots.Length > _slot)
    
  • Thank you.
    However, when I tried the fix, I got another error like this:

    error log:
    NullReferenceException: Object reference not set to an instance of an object
    AC.Menu.GetSlotCentre (AC.MenuElement _element, System.Int32 slot) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/Menu.cs:2787)
    AC.PlayerMenus.UpdateMenuPosition (AC.Menu menu, UnityEngine.Vector2 invertedMouse, System.Boolean force) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:867)
    AC.PlayerMenus.UpdateMenu (AC.Menu menu, System.Int32 languageNumber, System.Boolean justPosition, System.Boolean updateElements) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:992)
    AC.PlayerMenus.UpdateAllMenusAgain () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:2120)
    AC.PlayerMenus.UpdateAllMenus () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:2109)
    AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:232)

  • Thanks - I'll address this as well.

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.