Creating Container Displays
Step-by-step guide to setting up inventory displays for both player inventory and world containers in Ultimate Grid Inventory.
Understanding Container Displays
The Container Display is a crucial component in the Ultimate Grid Inventory (UGI) system that:
- Renders your inventory grids in the UI
- Works with the Display Filler to provide visual framing and styling
- Connects inventory data to visual representation
- Allows different display styles for different inventory types
You'll typically need multiple Container Displays in your game:
- One for the player's main inventory
- One for environment containers (chests, lockers, etc.)
- Additional ones for specialized inventories (crafting, shop, etc.)
Setting Up Container Displays
In this guide, we'll create two Container Displays:
- An environment container display for interacting with world objects
- A player inventory display with a custom visual style
Creating the Environment Container Display
First, we'll set up a scrollable area for environment containers like chests and backpacks.
Step 1: Create a UGI Scroll Area
- Follow the instructions in Creating a UGI Scroll Area to set up a scrollable container
- Position this scroll area where you want environment containers to appear in your UI
- Make sure the Content object inside the scroll area is properly configured
Step 2: Add the Container Display Component
- Select the Content GameObject inside your scroll area
- Add the
ContainerDisplay
component:- In the Inspector, click Add Component
- Search for "Container Display"
Container Display Component on ContentLoading image
Step 3: Create a Display Anchor
The Display Anchor is a Scriptable Object that connects container objects in your game world to this UI display.
- In your Project window, right-click in your desired folder
- Navigate to Create > Inventory > UI > New Container Display Anchor
Creating a Display Anchor SOLoading image
- Name it appropriately (e.g., "EnvironmentContainerDisplayAnchor")
Container Display Anchor CreatedLoading image
Step 4: Link the Display Anchor
- Select your Content GameObject with the ContainerDisplay component
- Assign your newly created Display Anchor to the "Display Anchor SO" field
Assigning the Display AnchorLoading image
Step 5: Configure Display Filler (Optional)
The Display Filler provides visual styling for your inventory grid. You can:
- Leave the "Prefab Display Filler" field empty to use the default style from your Inventory Settings
- Assign a custom prefab for a unique visual style for this specific container display
Understanding the Anchor System
The Container Display Anchor creates a connection between:
- Environment objects (chests, backpacks) with the
EnvironmentContainerHolder
component - UI elements with the
ContainerDisplay
component
When a player interacts with a container in the game world:
- The
EnvironmentContainerHolder
is activated - It finds the appropriate
ContainerDisplay
through the shared anchor - The container's inventory grid appears in your UI
Environment Container Holder ReferenceLoading image
This system allows you to have a single UI area that can display the contents of any container the player interacts with.
Creating the Player Inventory Display
Now let's set up the player's main inventory display with a custom visual style inspired by Resident Evil's inventory case.
Step 1: Create a Player Inventory Scroll Area
- Create another UGI Scroll Area for the player's inventory
- Position it in your desired location in the UI
Player Inventory Scroll AreaLoading image
Step 2: Add Container Display and Anchor
- Add the
ContainerDisplay
component to the Content GameObject - Create a new Display Anchor (e.g., "PlayerInventoryDisplayAnchor")
- Assign it to the Container Display
Player Inventory Container DisplayLoading image
Step 3: Link to Container Holder
If you've already set up a Container Holder for the player inventory (as described in Creating Holders):
- Find your Container Holder GameObject
- Assign the same Display Anchor to its "Container Display Anchor SO" field
Container Holder Anchor ReferenceLoading image
This creates a connection between the Container Holder (which manages container items) and the Container Display (which shows their contents).
Creating a Custom Display Filler
Let's create a stylized inventory background inspired by Resident Evil's attache case.
Step 1: Create the Display Filler
- Navigate to Ultimate Grid Inventory > Resident Evil Display Filler in the menu
- This creates a pre-configured GameObject with the necessary components
Resident Evil Display Filler MenuLoading image
Step 2: Save as Prefab
- Drag the created GameObject into your Project window to create a prefab
- You can customize the appearance by modifying the prefab's sprites and settings
Display Filler PrefabLoading image
Step 3: Assign to Player Container Display
- Select your player inventory's Container Display
- Assign your custom Display Filler prefab to the "Prefab Display Filler" field
Assigning Custom Display FillerLoading image
Testing Your Container Displays
After setting up both displays:
- Enter Play mode to test your configuration
- The player inventory should appear with your custom styling
- When interacting with environment containers, their contents should appear in the environment container display
Next Steps
Now that you've set up your Container Displays, you can:
- Create and configure items to populate your inventories
- Set up container items like backpacks and chests
- Implement interactive containers in your game world
- Customize the visual appearance of your inventory displays
With properly configured Container Displays, your inventory system will provide players with a visually appealing and functional interface for managing their items.