Forum rules - please read before posting.

[Request] Automated inventory item sorting by categories in the same Inventory Box

Hi there!

I'd love to be able to enable automated inventory sorting in the same Inventory Box, instead of having to create hard-to-maintain (because of style and settings) instances of the same Inventory Box, but each time picking a different category.

Integrated automated native nested per-localized name sorting within the same category (or, global, if there's just one category, or all categories are selected) would also be nice to have.

Comments

  • An inventory box displays items according to how they are placed in the player's inventory, any ordering would have to be done by manipulating the RuntimeInventory's localItems List.

    This could feasibly be done upon adding or removing an item via events:

    using UnityEngine;
    using AC;
    
    public class InventorySortExample : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnInventoryAdd += OnUpdateInventory;
            EventManager.OnInventoryRemove += OnUpdateInventory;
        }
    
        private void OnDisable ()
        {
            EventManager.OnInventoryAdd -= OnUpdateInventory;
            EventManager.OnInventoryRemove -= OnUpdateInventory;
        }
    
        private void OnUpdateInventory (InvItem invItem, int value)
        {
            KickStarter.runtimeInventory.localItems.Sort (delegate (InvItem a, InvItem b) {return a.binID.CompareTo (b.binID);});
        }
    
    }
    
  • That's a nice and clever quick fix, thanks Chris!

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.