Equipment View Slot Item. CanAdd function error

Johnny Mendez

New member
Hello Opsive,

As suggested in Discord. I write you here. Cause it's been now one day and I can't fix this issue by myself. I don't think the issue is related to the MAJ cause I already had it before the MAJ.

I have some equippable item in the inventory, I can drag them to the equipment view slot and if the item is a cape and I drag it to the Hat slot, it's red, so that's perfect.
When I drag it into the cape slot, it's not red so tha'ts cool, I wanna drop it into the slot to equip it. But nothing appen and the message bellow appear (When I drag it to the slot and appear again when I drop it into the slot)

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.UI.Panels.Hotbar.ItemSlotCollectionView.CanAddItem (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/Hotbar/ItemSlotCollectionView.cs:179)

You'll find in attachment my parameters. I also tried using the UI designer, but this is ever wors as the slots don't even appear.

Also, I am not sure if all is working fine cause, for now, I can equip an iem if I press "Equip" in the contextual menu, but I can equip like as much as item as I want, but I have only one slot for cape, Hat, weapon and magic.

I also tried by removing Item Slot Collection View. I wanted to send you video recoring, but the limit size of the attachment is really low. Do not hesitate to write me on Discord

I'll make you as much as capture as I can to help you.
 

Attachments

  • HierarchyOfGO.zip
    353.5 KB · Views: 3
In the future if you wish to send us a video you can use https://streamable.com/
It allows you to upload a video which will stay live for 30 days, any one with the url can access it.

Looking at the error and your screenshot I believe the problem is that your ItemSlotCollectionView is missing a reference to your Inventory.

In the first screenshot "HierarchyOfGO" you can see in the inspector that Inventory is missing.

That's usually ok if you have an "ItemViewSlotsContainerPanelBinding" component that is used to Initialize the ItemVewiSlotContainer (your ItemSlotCollectionView). The screenshot below shows it. When the DisplayPanel is opened it will bind the Inventory to the UI.
1607517352889.png
Note that "Bind To Panel Owner Inventory" field is set. This will use the Inventory that you defined as the panel owner on Display Panel Manager of the Inventory System Canvas game object

My guess is that the panel binding is missing, or that it does not point to the equipment Item View Slot Container game object.

Note there are two "Item View Slots Container Panel Binding" in the example image above. One is for the Inventory Grid and the other the equipment container which both needs to refresh/draw when the display panel is opened
 
Hi, thank you for this quick answer. So I did what you suggest by adding the binding componenet into Equipment Item View Slot Container. I checked in both (inventory grid ans equippment) the Bind to Panel Owner. But Issue remind same and now I can't equip (in blue) my items. only the weapons.

You'll find here a video, that's shows the bhaviour.

Thank you for the tips about streamable. that's awesome !


My target is just to visualy add the item into the equipment slots. I will try to equip them using my own script after that.

EDIT :

I add a little video https://streamable.com/7q55az

This is a strange behaviour also, cause I can equip as many item as I want. even if I have only one slot per item category. And that the first raw of the grid don'es act like the rest of the grid.
 
So first of all you have an error as soon as you play start, You should fix that before trying to fix other issues, as those issues could be an after effect of the first error.

After that there seems to be a problem with your "Equipped" Item Collection. it looks to me like you aren't using an ItemSlotCollection.
1607531451394.png
You can change the type of your Item Collection and you must set your Item Slot Set (The same as in the UI). This will limit the items you can add to that collection.

Also quick tip, You can have a better idea of what is going on by checking your inventory in the inspector at runtime (you can't add/remove items but you can check where are items are). This might help you find the problem

As for the for row in the grid not acting the same as the rest I'm sure what could cause that... Try to fix the rest first and we can go from there
 
Hi,

So I fixed all the issue I can. I noticed now that it's working if I put the player into my Item Slot Collection View.
But as soon as I change this parameter. There is other error messages and it's only working in the scene I set it up. When I start a new game, not working anymore.

I saw in the demo scene, there is no PLayer into this parameter. It's empty. But if I let it empty. I have the message I already sent to you with the CanAdd method.

Please find here a video of the situation


As I can see, it's a bit better. I can equip only one hat at a time and I can equip it in one scene but not between them.

Do you have any idea ?
 
So for the error about the you needing to set the player directly in the Item Slot Collection View. My suspicion is either you forgot to set the Panel Owner (But I doubt that since your inventory Grid is fine)
1607593273399.png
Or you do not have the ItemViewSlotsContainerPanelBinding (that I mentioned 2 posts above) set up correctly.

Double check both of those.

As for the rest I'm not sure...
You seem to have errors that happen outside of play mode... that is very odd, it would mean there is an event called when an object is destroyed.

The "Serialized Object Not Created Exception" is something I've rarely seen, I can't see if it has anything to do with UIS, it could be something else.

There seems to be an error with Pixel Crushers saving too... but that could be an after effect of the other errors.

I'm not sure what else you could try....

My advice would be to create a new scene with the bare minimum to have less variables to deal with, this way you should be able to track the problem.

As a last resort you can send me your minimal project that reproduces the bug and I can look at it in detail. If the problem originates from UIS I'll fix it.
 
Ah, I just thought of a reason you are getting an error!
The Game gameobject with the InventorySystemManager component. It looks like you aren't keeping the same one between scenes.

Make sure to tick this option:

1607614828240.png

This might explain why you are getting errors
 
I had to untick this box by following the procedure of PixelCrusher to use their Saving System. but now it works. I can't tell what really fixed the issue. But I start now to understand much better how to use your system. The video tutorials will help a lot. It's am Must.

Thank you for everything !
 
Top