Skip to content

03 — Search & Sort

Goal:
Learn how to find and order items dynamically inside an inventory — the foundation for searchable, sortable inventory UIs.


Purpose

Demonstrate live sorting and search through an inventory container using InventorySearchAndSortPanel.
Shows how to apply InventorySortSpec, highlight search hits, and combine both features for responsive UI behaviour.


🎓 What This Scene Teaches

  • Sorting containers with SceneInventoryService.Sort(...).
  • Primary/secondary keys via InventorySortSpec.
  • Search queries across names, categories, and tags.
  • Highlighting of search hits and active sort state.
  • Practical UI for sort toggles (Asc/Desc, Empty-last) and search input.

⚠️ Authority Note
This scene runs with Inventory authority permissive by default.
Inventory mutations are allowed locally for demonstration purposes.

Authority binders may appear in demo scenes to make the authority boundary explicit, but Inventory does not fail-closed by default.

Why demo scenes sometimes include binders:
https://revandrab.github.io/RevFramework/authority/#demo-scenes--binders-why-youll-sometimes-see-them


🧩 How to Use

  1. Assign 2–3 ItemDefinitions (different rarities or categories).
  2. Use Give to add items to the Backpack.
  3. Choose a Sort key (Name, Rarity, Category, Quantity).
  4. Toggle Asc / Desc and Empty ? End for order control.
  5. Press Apply Sort to reorder the container live.
  6. Enter a Search query (partial name, category, or tag) and click Find.
  7. Matching slots highlight; click Clear to reset.

💡 Key Takeaways

  • Sorting is stable — equal items retain their relative order.
  • Supported sort keys:
  • Name (case-insensitive, fallback to asset name)
  • Rarity (numeric)
  • Category
  • Quantity
  • Search matches displayName, NormalizedCategory, and NormalizedTags (case-insensitive).
  • Sorting is stable — equal items retain their relative order.
  • Sorting is a service-level mutation and respects authority checks.
  • Search is read-only and always allowed.
  • Both operations act on a single container.

🔧 Scene Setup

Component Purpose
InventorySearchAndSortPanel Teachable overlay demonstrating sorting and search.
SceneInventoryService Central service managing container operations.
CharacterInventory Holds the “Backpack” container.
InventoryAuthorityBinder Optional baseline authority binder (default allow; toggle off to simulate NoAuthority).
Property Default Notes
Container "Backpack" Configurable on the panel.
Toggle Key Backquote (```) Shows/hides the panel overlay.

Scene Path:
Assets/RevFramework/Runtime/Systems/Inventory/Samples/Scenes/03_Search_And_Sort/


📝 Notes

  • Sorting uses explicit InventorySortSpec to define key order and flags.
  • Searching returns an array of slot indices, which can be highlighted in UI.
  • Works standalone — no dependencies on Equipment, Currency, or Crafting.
  • Demonstrates production-style logic for runtime search/sort menus and debug panels.
  • Authority gating is supported via IInventoryAuthority.
    If no binder is present, service-level mutations default to allowed (single-player friendly).