Hello ORKnauts,

can someone please help me on how would be a C# script to change inventory items type? I don't want to use any input keys but simple buttons.
E.g. my inventory menu screen is ID:4 and I will put Item type IDs:1,2,3,4,5. I'll have unity toggle buttons to switch between them.

Cheers
  • You can use the menu screen part's SetOverrideType function for this, e.g.:
    MenuScreen screen = ORK.MenuScreens.Get(screenID);
    screen.part[partIndex].SetOverrideType(null, new List<int>() { 1 }, true);


    screenID is the ID/index of the menu screen.
    partIndex is the index of the menu part you want to access (e.g. 0 if it's the first added menu part of the menu screen).
    The available types are provided by an int list, containing the ID's of the item types.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks a lot!
  • Hello GiL,

    can this be used in ORK 3 to access also Menu Part -> Inventory -> Item Box Settings -> Sort By function?

    I want to change 'sort by' during runtime between 'Added, Buy Price, Float Variable'.
  • Yes - though it'd be easier to use the sorting options of the menu screen and e.g. change sorting via input key.

    Otherwise, yeah - the part field (array) of the MenuScreen class still holds the menu parts. You just need to check if it's the correct part and cast it to that type, e.g. InventoryMenuPart class.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited March 2023
    It looks like I need to set the AdvancedContentSorter class actually.

    public void SortNow()
    {
    MenuScreen screen = ORK.MenuScreens.Get(7);
    BaseMenuPart baseItem = screen.part[0];
    InventoryMenuPart inventoryItem = (InventoryMenuPart) baseItem;
    AdvancedContentSorter.Type sort = AdvancedContentSorter.Type.Name;
    AdvancedContentSorter contentSorter = new AdvancedContentSorter(sort);
    }

    But I'm getting an error:
    Assets\Sorting.cs(19,51): error CS1729: 'AdvancedContentSorter' does not contain a constructor that takes 1 arguments

    What am I doing wrong?
    Using ORK version 3.7.0 and Makinom 2.8.0
    Post edited by Machal on
  • The AdvancedContentSorter definitely has that constructor - but might be that it wasn't available in ORK 3.7 - update to the latest version (3.12) and it should be available.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • You were right, after the update, works fine, thanks a lot!
Sign In or Register to comment.