Wrong items loaded after rebuilding game


New member
@Sangemdoko after our quick chat on discord, here my forum post regarding "wrong items loaded after rebuilding the game".

I was trying to reprocude the issue by constantly rebuilding the game.
I even did some code changes, added and updated other packages via the package manager.
But the problem never appeared "forcefully".

It has however appeared 6-7 times over the past months, seemingly at random.

I currently do not know, if this issue will appear again and I want to prevent actual players from loosing game progress when releasing an update to my game.

Problem Description
Saving and loading items in the inventory works as expected.
But when building a new version of the game and loading a previously saved scene, wrong items are loaded.

Neither Item Categories, nor Item Definitions were changed between builds. In fact I have not touched UIS at all.
The player inventory was also not touched between builds.

While writing this post, I deliberately tried to reproduce the issue by rebuilding the project and trying different scenarios of collected, equipped, slotted items.
I was unable to reproduce it. When the problem appears "in the wild" there usually were days between the different builds, with lots of changes to the project, codebase, scenes, etc. No changes were made to the Inventory or Item Definitions, though.

So I assume that something else must change the unique IDs. Any idea what all could trigger an ID change?

Unity Version
I am currently using 2021.1.22f1, but the same issue appeared in any previous version (e.g. 2020.3.22f1)

Player / Build Configuration
Scripting Backend: IL2CPP
Api Compatibility Level: .NET 4.x
C++ Compilder Configuration: Release
Managed Stripping Level: Low

Thanks in advance :)
That's a really tricky one... You are the first person to point it out. So either it is something specific to your project, or it is something that is requires a certain level of complexity to reproduce.

What other assets are you using? In discord you mentioned the Pixel Crushers save system. Do you use the Opsive character controller or other assets which have integrations with UIS?

Once defined ItemCategories and ItemDefinition IDs should never change. Immutable Items that use the default values becomes a reference to the the Default Item of the ItemDefinition, so the Immutable Item ID should never change either.

Mutable Items are slightly different because they are created at runtime, so they are given randomly generated IDs. The way the save system works is by splitting the save data. The Inventory only saves the item ID + amount and tells the InventorySystemManagerItemSaver that the item with that ID must be saved.

When loading the InventorySystemManagerItemSaver loads all the items and then the InventorySaver will be able to find the item it wants by getting the item with a specific ID in the InventorySystemManager.

So the only reason I can think of is that your InventoryItemSetManager registers some items with different IDs before you are loading the save data.

This is the relevant code within InventorySystemManagerItemSaver:
if (InventorySystemManager.ItemRegister.TryGetValue(item.ID, out var registeredItem)) {
    var valueEquivalent = Item.AreValueEquivalent(item, registeredItem);
    if (m_SaveItemNames) {
        registeredItem.name = item.name;
    //An Item with the same ID is already loaded but has different values, replace attribute values
    if (valueEquivalent == false) {
        for (int j = 0; j < item.ItemAttributeCollection.Count; j++) {
            var attribute = item.ItemAttributeCollection[j];
            //Don't copy inherited values.
            if (attribute.VariantType == VariantType.Inherit) { continue; }
} else {
    InventorySystemManager.ItemRegister.Register(ref item);

Turns out if an Item with the same ID is already registered I don't log a warning or error... I just try to fix the attribute values.

At what point are you loading your save data?
If you load your save data after some items are already registered I'm not sure how the system could fix it... It's not really possible, because either the save item ID or the loaded item ID would need to change, add that could break a lot of things. If possible you should load the save data at the begining of the game in an isolated initialization scene. For loading a save data while the game is already playing you would destroy the InventorySystemManager (and other static components) and reload that initialization scene.

If you have some suggestions on changes we can make to the save system don't hesitate to ask. But I'm afraid there aren't that many options.
Thanks for the answer.

Yes I am using PixelCrushers Save System for UIS. The character controller is custom code. I am also using my own inventory / modular character system to display armor pieces and weapons equipped on the character. So initially, I was expecting my UIS integration to be the cause of this issue - which it wasn't. It actually works very well.

I am loading the item data when a scene with the player is loaded, while the game is already running. The initial scene does not contain an inventory or player. All items affected were mutable.

I am still searching for a way to reliably reproduce the issue on demand. Thanks for clariying how the system works and pointing me in a direction.
Once I have made progress - or have more questions - I'll post an update :)
Last edited:
Hi @Tzirrit any update on this issue? It seems another user (@Shanmukh ) has encountered it aswell. I really hope we can get to the bottom of this
I tried but was unable to reliably reproduce the issue, none of my initial ideas seemed to be the root cause.

The problem came and went, sometimes the IDs of mutable items changed with a build. The correct items are loaded, but since the ID is wrong/different, the wrong items get insanciated. However, the issue has not happened again recently and I put my focus on other priorities.

So if you or @Shanmukh have ways to reproduce it 100%, I can join in. Otherwise, I hope it won't happen again, especially once I shart shipping the game :)