Forum rules - please read before posting.

Dev Inventory

Hey people,
is it somehow possible to make an second inventory that works as a dev inventory. The features I would want are:

  • open on a hotkey (like shift p or something else)
  • spawn all avaible items in Inventory Manager on game start
  • is not affected by picking up items, combing in the real inventory

This is just to make sure we dont run in a softlock in our build.

Best
Celine

Comments

  • Welcome to the community, @Kirifox42.

    I should first note that it's possible to give all items to the Player while in Play mode via the "Give all to Player" menu item when clicking the cog icon in the Inventory Manager.

    If you're looking to have something similar, but in a separate Inventory, in builds, you'd need to do some custom scripting.

    Firstly, these items would need to be stored in a Container. This would need to be persistent - i.e. survive scene changes. Start by creating a new Container from the Scene Manager, make it a prefab, and then attach the Survive Scene Changes component. Remove from the scene, and use the Events Editor's Scene / Begin game event to run an Object: Add or remove Action to spawn it in. This will cause it to always be present in your game, regardless of which scene you begin from.

    Next, create a new Menu to display the items in, using an InventoryBox of the type "Container". Set this Menu's Appear type to On Input Key, and set the key to an input that's defined in your inputs list (either Input Manager or Input System).

    As part of its ActionList when turn on asset, run the Container: Open Action to open your Container prefab. Check Open in set element? and fill in the details of your new InventoryBox menu/element, so that the two link together.

    At this point, you should be able to open/close the display of your Container's items by pressing your chosen input. You can add one or two items to the Container from its Inspector just to confirm it's working.

    You should then just need a simple script to add all of your game's items to the Container when it gets added to the scene. You can do this by attaching the following (AddAllitems.cs) to your Container prefab:

    using UnityEngine;
    using AC;
    
    public class AddAllItems : MonoBehaviour
    {
    
        void Start()
        {
            Container container = GetComponent<Container>();
            foreach (InvItem item in KickStarter.inventoryManager.items)
            {
                container.InvCollection.AddToEnd(new InvInstance(item));
            }
        }
    
    }
    
  • Hey Chris, than you so much for that detailed tutorial.
    It works now, yay! I have a few questions.

    1. I can only drag and drop items (moving them areound generally), which are not tagged as "Carry on start" as soon as I tick that box in the inventory manager I can just click on the button slot. This doesnt matter for ours project at the moment, but I am wondering why.

    2. I made a custom Prefab in Unity and assigned the button to the inventory box. I noticed I can just set a maximum number of 30 slots. Is there a way to incrrease this? There is a workaround with just discarding a few items, but ideally we would need about 40 slots.

    Here are my Setings

    https://imgur.com/a/DXsA8B2

  • Okay, sorry, a few more observations:

    I cant discard items like I thought to get to the other slots, they all appear in the Inventory. I will try to write a simple scrolling script, thats already working on our normal inventory.

    To my first question I found out, of course I cant duplicate items when I drag and drop them, because I already have them in the current normal Inventory. We dont want to have more than one item of the same type at a time. So that works as wanted.

  • The cap on 30 should likely be removed, I'll look into this.

    In the meantime, you can adjust it manually by updating the MenuInventoryBox script's use of "30" around line 385.

  • Everything worked. Thank you!

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.