Release Candidate 3 Error

Hello, I am on the latest version for UIS and I am unable to open any of the editor windows of UIS. I get this error:

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Editor.Managers.DatabaseValidator.Validate (Opsive.UltimateInventorySystem.Core.ItemCategory itemCategory, System.Boolean autoFix) (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/DatabaseValidator.cs:203)
Opsive.UltimateInventorySystem.Editor.Managers.DatabaseValidator.CheckIfValid (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase database, System.Boolean autoFix) (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/DatabaseValidator.cs:105)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.ValidateDatabase () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:460)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.OnEnable () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:237)
UnityEditor.EditorWindow:GetWindow(Boolean, String)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow:ShowWindow() (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:121)
 

Sangemdoko

Moderator
Staff member
Hum...
That means your database is very wrong... My suspicion is that you used started changing the original demo database which is overwriten every time you'll update the asset.
When you start making assets for your game you MUST save them outside the Opsive folder. That's true for any type of asset: prefabs, scriptable objects, ect... are referencing.

My recommendation is to remove the UIS (and UCC integration if you are using that) before reimporting the latests version.

If I am mistaken and you created a database outside the opsive folder then the issue is that you mixed objects from two different databases. That's not something that is allowed.

I modified the code such that instead of a null exception error you'd get a warning.

Open the DatabaseValidator script and replace the code from line 186 to the end of the for loop by this:

C#:
 //Validate Parents.
            if (autoFix) {
                var amountRemoved = itemCategory.Parents.RemoveAll(x => x == null || x.IsInitialized == false);
                if (amountRemoved != 0) {
                    ItemCategoryEditorUtility.SetItemCategoryDirty(itemCategory);
                }
            }

            for (int i = 0; i < itemCategory.Parents.Count; i++) {
                var parent = itemCategory.Parents[i];
                if (parent == null) {

                    Debug.LogWarning($"Item Category {itemCategory} has a null parent.");
                    isValid = false;
                    continue;
                }

                if (parent.Children == null) {
                    Debug.LogWarning(
                        $"Item Category {itemCategory} has a parent {parent} which was not initialized, that means it isn't part of the database!");
                    isValid = false;
                } else {
                    if (parent.Children.Contains(itemCategory) == false) {
                        Debug.LogWarning(
                            $"Item Category {itemCategory} has a parent {parent} which does not reference it as a child.");
                        isValid = false;
                    }

                    var parentAttributeCount = parent.GetCategoryAttributeCount();
                    for (int j = 0; j < parentAttributeCount; j++) {
                        var parentAttribute = parent.GetCategoryAttributeAt(j);
                        if (itemCategory.HasCategoryAttribute(parentAttribute.Name) == false) {
                            Debug.LogWarning($"Item Category {itemCategory} is missing a Category Attribute named ${parentAttribute.Name}.");
                            isValid = false;
                        }
                    }

                    var parentItemDefinitionAttributes = parent.GetDefinitionAttributeList();
                    for (int j = 0; j < parentItemDefinitionAttributes.Count; j++) {
                        var parentAttribute = parentItemDefinitionAttributes[j];
                        if (itemCategory.HasDefinitionAttribute(parentAttribute.Name) == false) {
                            Debug.LogWarning($"Item Category {itemCategory} is missing a Item Definition Attribute named ${parentAttribute.Name}.");
                            isValid = false;
                        }
                    }

                    var parentItemAttributes = parent.GetItemAttributeList();
                    for (int j = 0; j < parentItemAttributes.Count; j++) {
                        var parentAttribute = parentItemAttributes[j];
                        if (itemCategory.HasItemAttribute(parentAttribute.Name) == false) {
                            Debug.LogWarning($"Item Category {itemCategory} is missing a Item Attribute named ${parentAttribute.Name}.");
                            isValid = false;
                        }
                    }
                }
Note it will be hard to salvage your corrupted database. If you can I would recommend making a new one from scratch correctly this time.
You should never duplicate a database of database object manually, if that's what you have done then it is what is causing this issue.
There is a new "duplicate" button in the editor window which allows you to duplicate databases the right way

I hop that helps
 
I still get an error:

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Editor.Managers.DatabaseValidator.Validate (Opsive.UltimateInventorySystem.Core.ItemCategory itemCategory, System.Boolean autoFix) (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/DatabaseValidator.cs:265)
Opsive.UltimateInventorySystem.Editor.Managers.DatabaseValidator.CheckIfValid (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase database, System.Boolean autoFix) (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/DatabaseValidator.cs:105)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.ValidateDatabase () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:460)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.OnEnable () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:237)
UnityEditor.EditorWindow:GetWindow(Boolean, String)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow:ShowWindow() (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:121)
 

Sangemdoko

Moderator
Staff member
Your database is quite corrupted. But I have an idea of what is going on.
The main issue is that you have an item category that is referenced by your other itemCategories but that category isn't part of the database.

I'll change the database validator taking that into account. I'll send you the new script so that you can test it out once I am done
 

Sangemdoko

Moderator
Staff member
Here is the new database validator.

You'll need to update the ItemDefinition, Currency and CraftingRecipe script by adding this line of code to each of them:

C#:
public bool IsInitialized => m_Initialized;
Let me know if you are still getting errors after that. If so I'll ask you to send us an email with your database so that we can have a look at it in depth.
 

Attachments

I am getting a ton of item definition errors from replacing the DV script but I realized that I had a test database in some part of my project now that I removed that data base and replace the DV script you gave me with the original it works. Here are the errors I get from your script:

Code:
Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(304,89): error CS1061: 'ItemDefinition' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'ItemDefinition' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(331,36): error CS1061: 'ItemDefinition' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'ItemDefinition' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(429,42): error CS1061: 'ItemDefinition' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'ItemDefinition' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(451,91): error CS1061: 'ItemDefinition' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'ItemDefinition' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(461,48): error CS1061: 'ItemDefinition' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'ItemDefinition' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(480,27): error CS1061: 'ItemDefinition' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'ItemDefinition' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(599,85): error CS1061: 'CraftingRecipe' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'CraftingRecipe' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(626,28): error CS1061: 'CraftingRecipe' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'CraftingRecipe' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(762,85): error CS1061: 'Currency' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'Currency' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(772,48): error CS1061: 'Currency' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'Currency' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\DatabaseValidator.cs(790,27): error CS1061: 'Currency' does not contain a definition for 'IsInitialized' and no accessible extension method 'IsInitialized' accepting a first argument of type 'Currency' could be found (are you missing a using directive or an assembly reference?)
 

Sangemdoko

Moderator
Staff member
I'm glad you were able to fix your problem.

The reason the script I gave you would not compile is because you didn't change the other scripts like I said was necessary:
You'll need to update the ItemDefinition, Currency and CraftingRecipe script by adding this line of code to each of them:

C#:
public bool IsInitialized => m_Initialized;
The changes will be added to the next version so hopefully you won't have these issues ever again.

To prevent having corrupted databases make sure to only create, remove and edit inventory objects within the main editor manager. If you create, remove or edit them manually in the project view you'll end up having a lot issues
 

mjdj1999

New member
Hello all! I'm kinda new at game design and I have done some searches on this error but I'm not able to find a solution and not very good with C# but I'm learning. I purchased the Ultimate Inventory a few months ago but have only recently been able to play around with it. After installing it I get 8 errors. I clicked on the "Integrations" in the main manager but it only goes to the store page on setting it up. All of the other Add-ons and integrations installed fine. Can someone shed some light on these errors? I'm confident that it is just something simple but I just cant put my finger on the fix. I just downloaded this from opsive.com today so it should be the latest version.


Assets\Opsive\UltimateInventorySystem\Editor\VisualElements\AttributeView.cs(55,31): error CS1061: 'CogButton' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'CogButton' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\SetupManager.cs(79,25): error CS1061: 'CogButton' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'CogButton' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\SetupManager.cs(193,20): error CS1061: 'Button' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\IntegrationsManager.cs(133,28): error CS1061: 'Button' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Managers\IntegrationsManager.cs(144,28): error CS1061: 'Button' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Inspectors\DatabaseInspectorBase.cs(132,20): error CS1061: 'Button' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\VisualElements\NestedScriptableObjectInspector.cs(36,48): error CS1061: 'Button' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)

Assets\Opsive\UltimateInventorySystem\Editor\Inspectors\InventorySystemManagerInspector.cs(360,20): error CS1061: 'Button' does not contain a definition for 'clicked' and no accessible extension method 'clicked' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)
 

Sangemdoko

Moderator
Staff member
Hi @mjdj1999

What Unity version are you using? It seems to me like you are using a version which does not have UIElements.
Ultimate Inventory System only works on Unity version 2019.3+ and it is highly recommended to use the 2019.4 LTS version.

Also you wrote your question in the "Pre-release" category on an open thread. I would highly recommend you open a new thread in the "Questions" category instead.
 

mjdj1999

New member
2019.2.19f1. I'm using my backup PC at the moment and when I opened the project on the storage server, I didn't realize that I was using an older version. Thank you.

My apologies. I searched the web for the error that I was getting (CS1061) and I found it here on this thread and thought it would be more appropriate to post here.

Thanks again!
 
Top