For the complete documentation index, see llms.txt. This page is also available as Markdown.

Pouch System

Overview

The Pouch example allows items to store other items inside them

Since instantiated GameObjects are not saved by default, this system uses pre-made pouch bags that are assigned dynamically.


Pre-Made Pouches

In the example, pouch bags are already set up in the scene:

Extended Inventory > Pouches

  • Includes 20 pre-made pouch bags

  • These act as bag instances

Adding More Pouches

If you need additional pouches:

  1. Duplicate existing pouch GameObjects

  2. Regenerate their:

    • Remember ID

    • Local Variables ID

This ensures each pouch works independently.


How It Works

Each pouch item is linked to one of the pre-made pouch GameObjects using an ID system.

On Hover Behavior

When hovering over a pouch item:

If Pouch-ID = 0 (no pouch assigned)

  • A free pre-made pouch is selected

  • The GameObject is assigned a unique name (1, 2, 3, etc.)

  • The same value is stored in the item's Pouch-ID property

If Pouch-ID has a value

  • The corresponding pouch is located

  • Its contents are previewed inside the tooltip


Item Setup (Required Properties)

To turn an item into a pouch, add the following properties to the Item asset:

  • Pouch-ID

    • Default: 0

    • Assigned automatically via Visual Scripting

  • Pouch-Height

    • Defines the number of grid rows

  • Pouch-Width

    • Defines the number of grid slots. If Pouch-Height is 1, and Pouch-Width is 5, there will be 5 slots. If Pouch-Height is 2, there will be 10 slots etc

  • Pouch-Full

    • Default: 0

    • Controlled via Visual Scripting


Important Limitation

Unity does not save instantiated GameObjects by default.

This system works around that by:

  • Using pre-existing pouch GameObjects

  • Assigning them dynamically via IDs

Optional: Supporting Instantiated Objects

If you want to support saving instantiated GameObjects, you can use Persistent Instances.

Persistent Instances This asset allows runtime-created objects to persist between sessions so spawned GameObjects can be saved and restored when loading a save.

Last updated