I have my inventory items set to add to the end, the inventory opens, hilights the latest item with a pulse and a sound, then closes the inventory again, I have never until now had so many items that they fill up the entire inventory menu so that I need to use the scroll arrows, so I never noticed before, but items now add to the end but offscreen to the right and I hear them hilight but can't see it. I would have thought it would automatically scroll to show the last item added and then hilight, So I think I must be doing something wrong in the set up of the inventory menu maybe? Hope that makes sense and that someone can help, thanks in advance!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Can you share screenshots to illustrate the issue? Share shots of the issue as it occurs in the game, as well as the Menus / ActionLists involved.
I'll also need details on how you're handling the "highlight last item" feature.
Hi Chris, thanks for the reply, here are the shots of the inventory menu, how I add the item, and the screenshot in game. In the shot, I just picked up a rock, I hear it add to the inventory but as it is at the end off to the right I can't see it add, then if I go up to the inventory and use the arrow to scroll right when the rock comes into view it then hilights! I would like to continue adding picked up items to the end though as the journal and map should always be first. I'm not sure what the 'hilight last item' feature is, so that's probably my problem!
(AC version is v1.60.4)
https://ibb.co/Ngj5BQ8p
https://ibb.co/4RwcNd5N
https://ibb.co/TDb3xMVC
Egads, that's 8 years old!
To shift to the end, you'd need to run the following code line:
Create a new C# script named FullyShiftInventory.cs and copy/paste:
Add to an Empty GameObject, make it a prefab, and then use the Object: Call event Action to run the prefab's Shift function, just after the Menu: Change state Action that turns the Menu on.
Perfect! That works great, thank you Chris! Ha, yeah 8 years old, I'm far too scared to update now!
Hi Chris, I'm sorry but this isn't working now, I swear it did when I first tried it but after making sure that I am 'carrying on start' the exact amount of inventory items to fill the on screen space, collecting something else doesn't shift the inventory to the end and show the new item, there is a warning on the action that says 'Parameters passed from here cannot be set, unfortunately, due to a Unity limitation' maybe it never worked and I somehow thought it did, sorry about that Chris, hopefully it can be edited to work? Action list image: https://ibb.co/ymzcbKq7
The warning can be ignored here because the function doesn't include any parameters.
We can try placing in a Debug.Log statement to confirm that it's being run by checking the console. Place this inside the Shift function:
However, I'd expect you'd need to run this event after the Inventory: Add or remove Action, as the effect isn't permanent. Once you add a new item, the Inventory will again go beyond the current offset.
Thanks Chris, that was it, I was opening the inventory, shifting it and then adding the item, changed it to shift after adding the item, all working great now, thanks again!
Hi Chris, sorry to bring this up yet again, but I have an error, I had been testing the shift inventory script by purposely filling up the inventory (10 slots in my case) so the next item would have to shift the inventory, then picking up a new item with the shift script on it just to test that it works, which it does and I thought that was all working, but after removing the extra inventory items again so that a new one just adds to the end on screen without the need to shift, it gives an error, sorry about this but I don't understand a word of it
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at :0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at :0)
AC.MenuInventoryBox.Display (UnityEngine.GUIStyle _style, System.Int32 _slot, System.Single zoom, System.Boolean isActive) (at Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuInventoryBox.cs:587)
AC.PlayerMenus.DrawMenu (AC.Menu menu, System.Int32 languageNumber) (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:561)
AC.PlayerMenus.DrawMenus () (at Assets/AdventureCreator/Scripts/Controls/PlayerMenus.cs:396)
AC.StateHandler._OnGUI () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:614)
AC.StateHandler.OnGUI () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:546)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
It still works as expected whether it needs to shift or not, but if it doesn't need to it gives a red error in the console
If this is still from AC v1.60, It's very likely a bug that's since been fixed.
Can you share a screenshot of the offending line - and code surrounding it? It's referring to line 587 of the MenuInventoryBox script.
Hi Chris, I'm not sure how much of the surrounding code is relevant, so here is a link to the whole script:
[REMOVED]
Please don't share the full script - this is still AC's source code.
Oddly, the line endings don't appear to match exactly but try replacing:
with:
Hey Chris, very sorry about that! I changed the line in the script and it shifts the whole inventory over leaving blank spaces athe the left, then when it closes again and I open the inventory normally everything is back to normal. I don't know what I'm doing here at all and I think I will just try and find out the max number of inventory items can be carried at any one time in the game and rescale the inventory box to accomodate that max number. Thanks for checking it out though.