Inventory script not saving item amounts in prefab


New member
Using Unity 2019.4.6f1
UIS Version: 1.0.2

I am using a duplicate of the prefab from the UCC integration demo that comes with an inventory component, but this occurs on anything with inventory component.

I click the + under item amounts and add items to the inventory. When I leave prefab view or select another gameobject in the prefab, the items amounts are empty.

When I add an item collection to the component with the + button, NewItemCollection1 doesn't appear on the collections list until I click away and click back to the gameobject with inventory component. It does appear as the selected collection that I can add item amounts to, but it isn't on the Item Collections list.

Workaround: I can get it to save item amounts by creating a new item collection every time I add items, but if I add items to an existing collection, they aren't saved.

I have prefab view on autosave and it doesn't appear to recognize that any changes have been made after adding items to the inventory component, it doesn't allow me to save manually after changing the inventory item amounts.



"I click the + under item amounts and add items to the inventory. When I leave prefab view or select another gameobject in the prefab, the items amounts are empty. "

ive had similar problems as well with pretty much anything you try to edit on the inventory script with it just reverting. Some how i manage to get it to work, which i cant explain. It just works "sometimes". Usually my go to is to save everything and if that doesnt work i restart Unity. I thought at first it might be related to the way unity is handling prefabs now. Ill have to test it more on non prefab game objects.


Staff member
I've been trying to reproduce this issue with no luck so far.
From what you are saying my guess is that "sometimes" the gameobject with the inventory does not get dirtied from the change on the inventory, when it is inside a prefab.

Could you try replacing the Function SetDirty of the InspectorUtility script to this:

/// <summary>
/// Flags the object as dirty.
/// </summary>
/// <param name="obj">The object that was changed.</param>
public static void SetDirty(UnityEngine.Object obj)
    if (obj == null || Application.isPlaying) {
    new SerializedObject(obj).ApplyModifiedProperties();
    if (obj is Component) {
        var component = obj as Component;
    } else if (obj is GameObject) {
        EditorSceneManager.MarkSceneDirty((obj as GameObject).scene);
    } else if (!EditorUtility.IsPersistent(obj)) {

If that does not fix it I'll try to find another solution. It is not trivial to fix as I can't seem to reproduce the issue.
Last edited:


Ill check on this tonight and see if i can reproduce in the new integration. Seriously strange bug.


New member
Sangemdoko your code fixed it perfectly in UIS 1.0.5 , sorry for late reply I took a break from working the inventory on my project but im back and it all seems smoother with the updates now