Forum rules - please read before posting.

Stacked Inventory Items and ArgumentException Error

Hi,

I'm using Unity 2018.3.11f1 and AC 1.67.4. I'm using a menu that appears on key press in the middle of the screen, and has multiple possible interactions on inventory objects, where the interactions are cycled with the right mouse button. The inventory itself is in a scroll view.

The issue I'm having is that when there are multiple stacked inventory items in the same slot, the action that normally selects the item (the default cursor) results in this error:

ArgumentException: You can only call GUI functions from inside OnGUI.
UnityEngine.GUIUtility.CheckOnGUI () (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:292)
UnityEngine.GUI.Label (UnityEngine.Rect position, UnityEngine.GUIContent content, UnityEngine.GUIStyle style) (at C:/buildslave/unity/build/Modules/IMGUI/GUI.cs:138)

The item is actually selected, but the game itself comes to a halt, of course. This only happens when clicking on items that are stacked and only when it's the select option (look etc works fine). For reference, my test involves 12 widgets stacked in a single inventory slot. The inventory has 24 slots. I don't have the inventory set to disappear or change in any way upon selection, but it is always just toggled with TAB.

Could I have a pointer as to where this error could be coming from?

Thanks in advance,

Selene

Comments

  • Sorry, you're going to have to elaborate on this - is this using custom scripting? The error message doesn't reference any AC code.

    If you can provide steps to recreate the issue, please share. If you're using a custom script to make this interface, you may need to do some extra work to disable the other menu items / temporarily pause the game to avoid all being clicked at once - which you can do via the menu custom events (see the Manual's "Menu scripting" chapter).

    I'm afraid I'm really not sure of the situation, however, so seeing more details about your setup will help me to understand better.

  • Thanks Chris. I'm not really doing anything too crazy with this project - I assumed the error was part of the Unity UI scripts or something similar. I wanted to provide an update though - checking "select one-at-a-time" for the inventory item removed the error, which works for my purposes now, though I assume if I really wanted an item that you could use all at the same time (e.g. a bag of coins) I'd have to revisit this issue.

  • edited April 2019

    Best for me to see this for myself.

    Please create a .unitypackage of your game's Managers, including your Inventory menu's UI Canvas prefab, and associated graphics. PM it to me and I'll take a look.

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.