Redirect to the Docs main page.Docs

UI

Creating Scrollable Inventory Areas

Learn how to implement and configure smooth-scrolling inventory areas that enhance player experience in Ultimate Grid Inventory.

Enhancing Inventory Navigation with Scroll Areas

Large inventories need effective scrolling solutions to remain user-friendly. The Ultimate Grid Inventory system includes a specialized component called ScrollRectInventory that significantly improves how players interact with scrollable inventory areas.

Why Use ScrollRectInventory?

The ScrollRectInventory component offers several advantages over standard Unity scroll views:

  • Drag-to-Scroll: Players can drag items near the edges to automatically scroll the view
  • Smooth Animation: Scrolling is smooth and responsive, enhancing the user experience
  • Customizable Sensitivity: Adjust scroll speed and sensitivity to match your game's feel
  • Intuitive Interaction: Players don't need to use the scroll wheel while dragging items
  • Mobile-Friendly: Works well on touch devices where scroll wheels aren't available

Creating a Scrollable Inventory Area

Create the ScrollRectInventory Component

To add a scrollable area to your inventory UI:

  1. In your UI scene, right-click in the Hierarchy panel
  2. Navigate to Ultimate Grid Inventory > ScrollRectInventory
  3. This creates a pre-configured GameObject with the ScrollRectInventory component

Creating the ScrollRectInventoryLoading image

The created GameObject includes:

  • A ScrollRectInventory component (enhanced version of Unity's ScrollRect)
  • A Viewport child object
  • A Content child object where your inventory elements will be placed

Customize the Appearance and Layout

Adjust the scroll area to match your UI design:

  1. Select the ScrollRectInventory GameObject
  2. In the Inspector, modify the RectTransform to set the desired size and position
  3. Customize the visual elements:
    • Add a background image to the main GameObject
    • Style the scrollbar to match your UI theme
    • Adjust the Viewport's mask settings if needed

Customizing the ScrollRectInventoryLoading image

You can also adjust technical settings:

  • Horizontal/Vertical: Choose which directions can scroll
  • Movement Type: How the content moves (Unrestricted, Elastic, Clamped)
  • Elasticity: How bouncy the scrolling feels at the edges
  • Scroll Sensitivity: How responsive the scrolling is to input

Configure Auto-Scroll Behavior

The auto-scroll feature activates when players drag items near the edges of the scroll area:

  1. Select your ScrollRectInventory GameObject
  2. In the Inspector, find the "Debug Gizmos" checkbox and enable it
  3. You'll see red dotted lines indicating the auto-scroll trigger areas

Debug Gizmos VisualizationLoading image

  1. Adjust the auto-scroll settings in your Inventory Settings:
    • Padding Percentage: How large the edge-trigger areas are
    • Scroll Speed: How quickly the view scrolls when triggered
    • Scroll Smoothing: How gradually the scrolling accelerates

The Debug Gizmos are only visible in the Unity Editor and won't appear in your final game build. They're a development tool to help you visualize and configure the auto-scroll areas.

Add Inventory Content

Now you can add inventory elements to your scrollable area:

  1. Select the Content child object of your ScrollRectInventory

  2. Add your inventory components to this object:

    • For container displays, add the Container Display component
    • For grid displays, add your grid visualization elements
    • For item lists, add your item UI elements
  3. Make sure the Content's height is set appropriately:

    • For dynamic content, you may need to use a ContentSizeFitter
    • For fixed grids, set the height manually to accommodate all items

Testing Your Scrollable Inventory

To ensure your ScrollRectInventory is working correctly:

  1. Enter Play mode in the Unity Editor

  2. Try these interactions:

    • Drag an item near the top/bottom edges to trigger auto-scrolling
    • Use the scrollbar to navigate the inventory
    • Use the mouse wheel to scroll (if enabled)
    • Verify that items can be dragged between different parts of the scrollable area
  3. Check for these common issues:

    • Content not fully visible (adjust Content size or ScrollRect settings)
    • Scrolling too fast or too slow (adjust scroll speed in Inventory Settings)
    • Auto-scroll not triggering (check padding percentage settings)

Next Steps

After setting up your scrollable inventory areas, you can:

Properly configured scroll areas are essential for creating user-friendly inventory interfaces, especially for games with large inventories or limited screen space. They allow players to navigate their items smoothly and intuitively, enhancing the overall gameplay experience.

On this page