error when removing a category

Reza

Member
The following error

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Core.AttributeSystem.RequiredItemDefinitionAttributeCollection.GetInheritOfAttribute (Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase attribute) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/RequiredItemDefinitionAttributeCollection.cs:90)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase.GetInheritAttribute () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeBase.cs:439)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetInheritedValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:144)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated, System.Boolean checkIfBound) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:352)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetInheritedValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:151)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated, System.Boolean checkIfBound) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:352)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetVariantValue () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:320)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].ReevaluateReturnValue (System.Boolean setAsPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:288)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].ReevaluateValue (System.Boolean setAsPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:278)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.ReevaluateAll (System.Boolean setPreevaluate) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:489)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.CreateNewAttributesIfMissing (Opsive.Shared.Utility.ListSlice`1[T] requiredAttributes) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:269)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.UpdateAttributesToMatchList (Opsive.Shared.Utility.ListSlice`1[T] requiredAttributes, System.Boolean removeAdditionalAttributes) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:228)
Opsive.UltimateInventorySystem.Core.ItemDefinition.UpdateAttributes () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/ItemDefinition.cs:744)
Opsive.UltimateInventorySystem.Core.ItemDefinition.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/ItemDefinition.cs:202)
Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/Storage/InventorySystemDatabase.cs:259)
Opsive.UltimateInventorySystem.Editor.Managers.DatabaseValidator.CheckIfValid (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase database, System.Boolean autoFix) (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/DatabaseValidator.cs:97)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.ValidateDatabase () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:475)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.OnEnable () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:243)
UnityEditor.EditorWindow:GetWindow(Boolean, String)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow:ShowWindow() (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:122)
 
Hi @Reza You'll need to go to the RequiredItemDefinitionAttributeCollection script and replace the following function by the snippet below:

C#:
public override AttributeBase GetInheritOfAttribute(AttributeBase attribute)
        {
            var parentCount = m_ItemCategory.ParentsReadOnly.Count;
            for (int i = 0; i < parentCount; i++) {
                //First come First served order of parents matters
                var parent = m_ItemCategory.ParentsReadOnly[i];
                if(parent == null){ continue; }
                if (parent.TryGetDefinitionAttribute(attribute.Name, out var output)) {
                    return output;
                }
            }

            return null;
        }

Can you explain what you did in detail?

1) Is the database that is having issues the integration database in the Opsive folder or the database you created for our own project?
2) The error above can only happen if you removed a category outside of the editor manager.It is important not to touch the database objects outside of the editor otherwise other objects in the database are corrupted.
3) When making your own project make sure not to use prefabs from the demo scene directly as these can change or can even get deleted with updates. So make sure to create new prefabs for your project if that's not already the case
4) Don't forget to make a backup before downloading an update, it's good practice and it can save you a lot of hassle
 
1. the database is my own database which I duplicated from the old integration database then when I open it looks like my database was overwritten by the database of the new integration

2. I didn't delete it from outside the editor. I deleted it through the UIS editor, as usual
 
Ok.

Where did you save your own database? I do not see how it could have been overwritten by the update if it was saved outside the Opsive sub folders

Did the code change specified above help you access the UIS editor?
 
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Core.AttributeSystem.RequiredItemAttributeCollection.GetInheritOfAttribute (Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase attribute) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/RequiredItemAttributeCollection.cs:93)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeBase.GetInheritAttribute () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeBase.cs:439)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetInheritedValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:144)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated, System.Boolean checkIfBound) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:352)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetInheritedValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:151)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetValueInternal (Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T] relativeAttribute, System.Boolean checkIfPreEvaluated, System.Boolean checkIfBound) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:352)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].GetVariantValue () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:320)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].ReevaluateReturnValue (System.Boolean setAsPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:288)
Opsive.UltimateInventorySystem.Core.AttributeSystem.Attribute`1[T].ReevaluateValue (System.Boolean setAsPreEvaluated) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/Attribute.cs:278)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.ReevaluateAll (System.Boolean setPreevaluate) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:489)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.CreateNewAttributesIfMissing (Opsive.Shared.Utility.ListSlice`1[T] requiredAttributes) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:269)
Opsive.UltimateInventorySystem.Core.AttributeSystem.AttributeCollection.UpdateAttributesToMatchList (Opsive.Shared.Utility.ListSlice`1[T] requiredAttributes, System.Boolean removeAdditionalAttributes) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/AttributeSystem/AttributeCollection.cs:228)
Opsive.UltimateInventorySystem.Core.Item.UpdateAttributes () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/Item.cs:461)
Opsive.UltimateInventorySystem.Core.Item.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/Item.cs:294)
Opsive.UltimateInventorySystem.Core.ItemDefinition.DeserializeAttributeCollections () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/ItemDefinition.cs:224)
Opsive.UltimateInventorySystem.Core.ItemDefinition.Deserialize () (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/ItemDefinition.cs:212)
Opsive.UltimateInventorySystem.Core.ItemDefinition.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/ItemDefinition.cs:159)
Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/Storage/InventorySystemDatabase.cs:259)
Opsive.UltimateInventorySystem.Editor.Managers.DatabaseValidator.CheckIfValid (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase database, System.Boolean autoFix) (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/DatabaseValidator.cs:97)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.ValidateDatabase () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:475)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.OnEnable () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:243)
UnityEditor.EditorWindow:GetWindow(Boolean, String)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow:ShowWindow() (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:122)
 
That is quite concerning... I'll be testing some things to try and reproduce your issue with the database corruption.

For now fix the new error by replacing this function in the RequiredItemAttributeCollection

C#:
 public override AttributeBase GetInheritOfAttribute(AttributeBase attribute)
        {
            var parentCount = m_ItemCategory.ParentsReadOnly.Count;
            for (int i = 0; i < parentCount; i++) {
                var parent = m_ItemCategory.ParentsReadOnly[i];
                if(parent == null){ continue; }
                //First come First served order of parents matters
                if (parent.TryGetItemAttribute(attribute.Name, out var output)) {
                    return output;
                }
            }

            return null;
        }
 
I have been trying to replicate the bug you had with your database for the past hour but everything seem to work fine.
Next time there is an update to package make sure to do a backup and let me know if you get a corrupted database again.

It is possible that there used to be a bug with the Duplicator when you first duplicated your database and that's why I can't reproduce it.
You could try to duplicate your current database just to see what happens
 
Did you maybe have another instance of unity open and referenced the demo DB inside one of the wizards? I *think* I saw a situation where the wizards seem to overwrite each other state when you have 2 instances of the inventory editor windows open?
 
Top