Hello. Sry for my english.
In order to create an exam menu for inventory items, I created a menu where each inventory item corresponds to a previously disabled element. Right-clicking on an inventory item along with opening the menu shows the corresponding element of this menu, and when closing the menu, all elements are disabled. There are about a hundred items in this menu. So at the first exam of any inventory item, a freeze occurs for half a second. I don't like it. I may have made mistakes in the realisation.
I would be grateful if you point them out.
Thx
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
At the moment, the only acceptable solution for me is to open and close this menu for the first time during the loading screen of the scene. But I would like to reach a more correct solution.
Is this to say that the freeze only occurs for the first time the Menu is opened / inventory item is clicked?
To be clear: you're listing over 100 inventory items in order to run their "Use" interaction when clicked? Are you similarly involving 100 menu elements, or do you add/remove items dynamically to show different items at different times?
What are your AC/Unity versions, and are you using Unity UI? Please share as much detail (including screenshots if possible) to help explain the specifics of the situation.
An alternative approach would be to assign your ActionLists directly in each UI Button component's "On Click" event, then selecting its Interact function so that it runs when clicked. Such a Button needn't then be linked to AC's Menu Manager as a Button element. If you wanted to show/hide Buttons dynamically, you could then either rely on scripting, or animation.
Yes, that's right. The frieze occurs only at the first opening.
The menu opens when the right mouse button is clicked. When the item is examined. I dynamically hide and show menu elements (these elements are hidden by default) to open a window corresponding to a specific inventory item.
AC version is v1.75.3
Unity Version is 2020.3.30f1.1607
I use Unity UI.
https://disk.yandex.ru/i/w48VgseuJxt54w
https://disk.yandex.ru/i/FfgDUDJfrNGMJw
This is the menu. There are fewer objects that there should be. But even in this form, a frieze occurs. Each of the selected objects corresponds to an inventory item and a menu element that is hidden by default.
https://disk.yandex.ru/i/Bv6bPczU-vncWA
Examine ActionList for specific item.
https://disk.yandex.ru/i/cLAXJzrPvcuGgA
ActionLis when turn off menu.
https://disk.yandex.ru/i/B2yXe66PfWPbfg
This is how the menu looks for a specific item.
Thx alot.
https://disk.yandex.ru/i/jXE9qSLn9-TuHw
What the inspector looks like for each menu object.
How do the elements relate to your Inventory items? The standard way to show items dynamically would be to use an InventoryBox element that reads the Player's Inventory (or a Container, through scripting).
Do you still get the freeze if the BigInventoryItemMenu_TurnOff asset is not run?
If so, the issue may be less to that, and instead to do with the initialisation of the menu. In this case, you can either force the initialisation on startup with a script:
Or reduce the number of elements linked to Unity UI components. If you are just dealing with Images in the Canvas prefab that you want to show/hide at different times, you could reference them in a dedicated script attached to the prefab instead. What are the conditions for showing/hiding these Images?
Yes. The frieze is still present.
Initialization at the start of the scene also, unfortunately, does not help.
In any case, as you rightly noted, my realisation was heavy and non-standard.
And since I don't really want to resort to writing even the simplest scripts if it's not vital, I solved the problem with the help of an animator - now I'm changing images using an animator directly in ActionLists. There was only one image-object left in the menu instead of 100. And the friezes, of course, disappeared.
Thanks.