The Object you want to instantiate is null

Hey,
the typically “yesterday was all fine”-problem.
error message:

i think the problem is at line 32, but i dont know whats wrong here

can anyone help me?

My guess is “itemSlotContainer” is a public RectTransform or assigned elsewhere and the error is for it having no reference… so if you select whatever has the UI_Inventory Component in the Hierarchy and look in the Inspector you might find “Item Slot Container” and it says “None (Rect Transform)” or missing and just needs you to drag-and-drop the “item slot container” (whatever that is) into that. That’s one possibility to start with anyway.

Thanks for your response.

here are the Hierarchy, its a UI:

ItemSlotContainer is empty, as it should:

within itemSlotTemplate is a GO called image:

is here at image the problem?
it has none source image because it get his image from a List:

And the ItemAssets is into a GO:

i hope this makes it possible to find the problem. I thank you for your help

In your first image, there’s a child of Canvas there called “UI_Inventory”. If you click that, do you see anywhere that says “Item Slot Container” in the Inspector? If it’s there, then drag the object you have highlighted (itemSlotContainer) into that - if that’s not it, please show your UI_Inventory Inspector.

Sadly no

…and the lines above 25 in UI_Inspector.cs?

Edit: UI_Inventory.cs - sorry

here. i want to say: thnk you. for your help and patience.

Okay - change “private Transform itemSlotContainer;” to start with “public”, then view UI_Inventory in the Inspector, drag the “itemSlotContainer” from that image into that slot ?

ok done. this is the result:

error:

this line is in the post above, but here:
Image image = itemSlotRectTransform.Find(“image”).GetComponent();

That’s saying either…
a) there’s no reference in itemSlotRectTransform (in which case change that to public as well try dragging whatever you think belongs there that has a child object called “image” into it)
b) if there is a reference in itemSlotRectTransform, there’s no child of it called “image”

Ok, as i can say it was a.
at this point i can start the game. got 1 new error but i think i can/try to solve it myself.

i thank you very much for your help, i struggled a few hours.

1 Like