Dialogue System
The Dialogue System integration lets a conversation read or change Ultimate Inventory System Items and Currency. A merchant can offer a response only when the player owns a Health Potion, remove that potion, award Gold, or open an Ultimate Inventory System Shop without duplicating Inventory data inside the dialogue database.
Pixel Crushers maintains this integration for Dialogue System 2.x. Use a bridge package that explicitly matches released Ultimate Inventory System Version 1 and the installed Dialogue System release. The installer does not declare a minimum or maximum Dialogue System version, and Pixel Crushers updates it independently of Ultimate Inventory System, so a package that merely has the same filename is not enough evidence of compatibility.
Before you begin
- Install and compile Ultimate Inventory System Version 1 and Dialogue System 2.x before importing the bridge.
- Confirm that the player’s Ultimate Inventory System Inventory and Currency Owner work outside a conversation.
- Give every Item Definition, Currency, Item Collection, shop object, and scene owner a stable, exact name. The Lua bridge resolves these names at runtime.
- Decide which product owns saving before adding a saver. Do not let both systems write and restore the same state independently.
Sign in to Opsive Downloads and download the Dialogue System integration after both products compile. The bridge is not included in the base product’s Integrations folder before download; importing the matched package creates the integration files in the project. See the Pixel Crushers Ultimate Inventory System integration manual for provider-specific changes.
Install and enable the bridge
- Back up the project and remove an older duplicate of the two Opsive UIS Support folders if you are replacing the integration.
- Import the matched
DialogueSystem.unitypackageafter both products compile. - Confirm that Unity installs support scripts beneath these folders:
Assets/Pixel Crushers/Common/Third Party Support/Opsive UIS SupportAssets/Pixel Crushers/Dialogue System/Third Party Support/Opsive UIS Support
- Select the persistent Dialogue Manager GameObject and add UIS Lua from Pixel Crushers > Dialogue System > Third Party > Opsive > UIS Lua.
- Leave Unregister On Disable off for a persistent Dialogue Manager. Enable it only when this component should remove all six Ultimate Inventory System Lua functions when disabled.
- Open the Dialogue Editor and confirm that the Lua wizard lists the Ultimate Inventory System condition and script functions supplied by
UIS Lua Function Info.asset.
The bridge uses the existing Ultimate Inventory System Inventory Database. It does not copy Items, Currency, or Shops into the Dialogue System database.
Create an Item-for-Gold conversation
This example shows a response only when the player owns a Health Potion, then trades one potion for five Gold.
- Tag the player GameObject Player. Put its Ultimate Inventory System Inventory and Currency Owner on that object or one of its children.
- In a response dialogue entry, enter this Lua in Conditions:
uisGetItemAmount("Health Potion", "") >= 1
- In the same entry’s Script, remove the potion and award the Gold:
uisRemoveItem("Health Potion", 1, "", "")
uisAddCurrency("Gold", 5, "")
- Add another response for the case where the player has no potion, or let the unavailable response remain hidden according to the conversation’s response settings.
- Use the exact Ultimate Inventory System names Health Potion and Gold. The empty owner strings tell the verified bridge to find a GameObject tagged Player.
- After the script runs, check the Inventory and Currency display. The change functions do not return a success value to Lua, so visible state or a follow-up get function is the reliable result.
This keeps the dialogue decision in Dialogue System while Ultimate Inventory System remains the source of truth for the Item and Gold balances.
Use the Lua functions
| Goal | Function | Important behavior |
|---|---|---|
| Read an Item amount | uisGetItemAmount(itemName, inventoryName) |
Returns a number. A blank owner uses a GameObject tagged Player. |
| Add an Item | uisAddItem(itemName, amount, inventoryName, itemCollectionName) |
Adds an integer amount. A blank collection uses the Inventory’s normal add route. |
| Remove an Item | uisRemoveItem(itemName, amount, inventoryName, itemCollectionName) |
Finds a matching Item and requests removal. Recheck the amount when the result matters. |
| Read Currency | uisGetCurrencyAmount(currencyName, currencyOwnerName) |
Returns the Currency Owner’s amount as a number. |
| Add Currency | uisAddCurrency(currencyName, amount, currencyOwnerName) |
Adds the configured Currency amount and returns no Lua result. |
| Remove Currency | uisRemoveCurrency(currencyName, amount, currencyOwnerName) |
Requests removal and returns no Lua result; check the balance first when insufficient funds must choose another branch. |
For a named owner, the bridge searches for that GameObject, then looks for an Inventory or Currency Owner on it or its children. For a blank owner, it searches by the Player tag. Item names and Currency names are resolved through InventorySystemManager.
Item amounts arrive from Lua as numbers but are converted to integers. Do not use fractional Item amounts. Currency amounts remain numeric and follow the Currency’s configured precision and conversion rules.
If Item Collection Name is present, it must exactly match an Item Collection on the resolved Inventory. In the verified source, a missing collection name falls back to the broader Inventory route instead of reporting an error, so verify the affected collection after every dialogue action.
Use quests and Shops
Dialogue System quest conversations can use the same functions in dialogue-entry Conditions and Script fields. For example, require a quest giver to see one Iron Sword with uisGetItemAmount, then award Gold with uisAddCurrency when Dialogue System advances the quest state. The quest state still belongs to Dialogue System; the integration only reads or changes Ultimate Inventory System data.
Pixel Crushers Quest Machine uses a separate integration. Use the Quest Machine integration when the quest itself is a Quest Machine quest rather than a Dialogue System quest.
The package also adds the sequencer command OpenShop(). The most reliable setup for the verified package is:
- Put an Ultimate Inventory System Shop component on the conversation speaker. The sequencer command accepts this concrete
ShopBaseimplementation. - Make the player the conversation listener and give it an Inventory, or tag the player Player.
- Keep an Ultimate Inventory System Shop Menu in the scene beneath a Display Panel Manager.
- Enter
OpenShop()in the dialogue entry’s Sequence field.
When the sequence runs, the command finds the Shop, assigns the player’s Inventory as the client, assigns the Shop to the menu, and asks the Display Panel Manager to open it. Verify the no-argument form before using optional subjects because their handling depends on the integration revision.
Choose one save owner
Saving is the area most likely to differ between provider revisions. Follow the files and instructions included with the matched bridge. The installer verified for this page contains two mutually exclusive routes:
| Save owner | Components in the verified installer | Rule |
|---|---|---|
| Pixel Crushers Save System | UIS Saver on the Pixel Crushers Save System object and Save System Manager No Disk in place of the normal Ultimate Inventory System disk-writing manager | Pixel Crushers stores the combined saved game. Keep Save Slot at 0 for this archived bridge because its load path restores slot 0. |
| Ultimate Inventory System Save System | Pixel Crushers to UIS Saver registered with the Ultimate Inventory System Save System | Ultimate Inventory System records and restores Pixel Crushers saved-game data. Do not also add UIS Saver. |
Do not configure both rows. Also do not ship the demo’s Redirect Save Load Button To Test Menu component; its source explicitly marks it as test-only.
If a newer integration Inspector says that one of these legacy components is no longer used, follow that newer package’s instructions rather than recreating the archived setup.
Editor checkpoint
Before entering Play Mode, confirm all of the following:
- Unity has one copy of each Opsive UIS Support script and no compile errors.
- The persistent Dialogue Manager has one enabled UIS Lua component.
- The Lua wizard shows
uisGetItemAmount,uisAddItem,uisRemoveItem,uisGetCurrencyAmount,uisAddCurrency, anduisRemoveCurrency. - The Player tag or explicit owner name resolves to the intended Inventory and Currency Owner.
- Health Potion, Gold, Item Collection names, and Shop subjects exactly match the Ultimate Inventory System configuration.
- Exactly one save system owns the combined save, and the project does not contain both saver routes.
Verify in Play Mode
- Start with one Health Potion and zero Gold. Begin the conversation and confirm that the trade response is available.
- Select the response. Confirm that the potion amount decreases by one and Gold increases by five in Ultimate Inventory System, not only in a dialogue variable.
- Start the conversation again. The response should now follow the no-potion path.
- Test a misspelled Item name on a copy of the conversation. With Dialogue System warning logging enabled, the Console should identify the missing definition and Ultimate Inventory System state should remain unchanged.
- Run the Shop conversation and confirm that
OpenShop()opens the Ultimate Inventory System Shop Menu with the expected Shop and player Inventory. - Save, change the Item and Gold balances, then load. Confirm that dialogue/quest state and Ultimate Inventory System state return together exactly once.
- Reload the scene and repeat the conversation to catch duplicate Dialogue Managers, duplicate Lua registration, or a missing persistent save owner.
Troubleshooting
| Symptom | Check | Fix |
|---|---|---|
| Unity reports missing Pixel Crushers namespaces after import | Check whether Dialogue System compiled before the bridge and whether the bridge matches Dialogue System 2.x. | Remove the incomplete support folders, install the prerequisite, and import one matched integration package. |
Lua reports an unknown uis... function |
Check that one enabled Ultimate Inventory System Lua component exists on the active Dialogue Manager and whether Unregister On Disable removed the functions. | Enable the correct component, avoid duplicate Dialogue Managers, and restart the scene after registration. |
An Item or Currency get function returns 0 |
Check the exact Ultimate Inventory System name, Player tag or explicit owner name, and component location. | Correct the name and make sure Inventory or Currency Owner exists on the resolved object or a child. |
| A change function runs but state does not change | Check the target, collection name, available amount, and Inventory restrictions. | Recheck with the corresponding get function and treat an unchanged value as failure. |
| The wrong Item Collection changes | Check spelling and capitalization of Item Collection Name. | Use the exact collection name; a missing match can fall back to the broader Inventory route in the verified package. |
| Remove Currency continues even when funds are insufficient | The Lua change function does not return the Ultimate Inventory System removal result. | Put uisGetCurrencyAmount(...) >= price in Conditions before running the removal script, then verify the balance. |
OpenShop() logs that a subject, menu, manager, or Inventory is missing |
Check the speaker’s Shop component, listener/player Inventory, Shop Menu, and parent Display Panel Manager. | Make the no-argument convention work first, then add explicit subjects only when the installed integration documents them. |
| Loading duplicates or loses Ultimate Inventory System data | Check for both saver routes, two disk writers, duplicate saver keys, and a nonzero slot in the archived UIS Saver. | Choose one save owner, keep unique saver keys, and verify a new slot-0 save before migrating existing saves. |
| Quest Machine does not react to these Lua functions | Check whether the quest belongs to Quest Machine rather than Dialogue System. | Install and configure the separate Quest Machine integration. |
Related pages
Developer and version reference
The Ultimate Inventory System Version 1 package verified for this page is version 1.3.0. Its checked-in DialogueSystem.unitypackage contains UISLua, UISUtility, SequencerCommandOpenShop, UISSaver, SaveSystemManagerNoDisk, PixelCrushersToUISSaver, a demo scene and database, and UIS Lua Function Info.asset. It contains no manifest that pins a Dialogue System version. Pixel Crushers release notes show that the provider updates this bridge between Dialogue System 2.x releases, so source from the matched download takes precedence over an older copied folder.
UISLua registers all six functions in OnEnable. Unregister On Disable defaults to false; when enabled, OnDisable unregisters them. A blank owner name uses a Player-tagged GameObject, while a nonempty name uses Pixel Crushers’ hard GameObject lookup. The component then searches the object and its children for Inventory or Currency Owner.
The Item change functions accept a Lua number and cast it to int. All four change functions return void, so a dialogue script cannot infer success from the call itself. The get functions return double, and the integration logs missing-name or missing-owner warnings only when Dialogue System warning logging is enabled.
In the archived source, UISSaver.ApplyData restores Ultimate Inventory System save index 0 even though the component exposes Save Slot, and SequencerCommandOpenShop does not reliably consume its documented optional player-inventory subject. Keep the saver on slot 0 and prefer OpenShop() with speaker/listener defaults unless a newer matched integration corrects those behaviors.