Forum begins after the advertisement:
[Part 5] Slot inventory
Home › Forums › Video Game Tutorial Series › Creating a Farming RPG in Unity › [Part 5] Slot inventory
- This topic has 16 replies, 4 voices, and was last updated 1 month ago by
Tarha Apustaja.
-
AuthorPosts
-
July 23, 2025 at 3:10 am #18565::
Thank you for sharing the screenshot of the UI Manager. However, I’m unable to view images directly.
To help you better, please describe what you see in the UI Manager. Here are a few questions that can help clarify the situation:
- Have you assigned the necessary UI elements (like buttons, panels, etc.) to the UI Manager in the Inspector?
- Are there any specific fields in the UI Manager that you are unsure about?
- Are you encountering any errors or issues related to the UI Manager when testing your game?
Feel free to provide any details or questions you have, and I’ll do my best to assist you!
July 23, 2025 at 9:16 am #18566::Could you take a screenshot or a short recording of how each inventory slot shows up in the index value when in play mode?
July 29, 2025 at 3:52 am #18593::So before I do that I exited out of unity and came back to it today and it now has this error is hasnt been showing up until today. I will post it here and take a screen shot of it.
NullReferenceException: Object reference not set to an instance of an object InventorySlot.Display (ItemData itemToDisplay) (at Assets/Scripts/UI/InventorySlot.cs:30) UIManager.RenderInventoryPanel (ItemData[] slots, InventorySlot[] uiSlots) (at Assets/Scripts/UI/UIManager.cs:100) UIManager.RenderInventory () (at Assets/Scripts/UI/UIManager.cs:74) UIManager.Start () (at Assets/Scripts/UI/UIManager.cs:45)
Here is a screenshot. https://imgur.com/a/oHv76mi
July 29, 2025 at 3:55 am #18594::Based on the error trace, this looks like a null reference issue in your InventorySlot.Display method, specifically on line 30. This typically means one of two things:
- Your InventoryManager’s tools or items arrays are not fully populated
- Your InventorySlot references in the UI Manager are not correctly assigned
To diagnose:
- Check that InventoryManager has valid ScriptableObject items in its tools and items arrays
- Verify all InventorySlot references in UIManager are properly assigned in the Inspector
- Ensure no slots are left empty or unassigned
Can you confirm:
- Are all tool and item slots in InventoryManager filled with ScriptableObject instances?
- Did you recently modify your inventory setup or scripts?
July 29, 2025 at 4:18 am #18595::Now its saying this
NullReferenceException: Object reference not set to an instance of an object InventorySlot.Display (ItemData itemToDisplay) (at Assets/Scripts/UI/InventorySlot.cs:38) UIManager.RenderInventoryPanel (ItemData[] slots, InventorySlot[] uiSlots) (at Assets/Scripts/UI/UIManager.cs:100) UIManager.RenderInventory () (at Assets/Scripts/UI/UIManager.cs:74) UIManager.Start () (at Assets/Scripts/UI/UIManager.cs:45)
July 29, 2025 at 4:20 am #18596::Based on the error trace, this is still a null reference issue, now occurring on line 38 of InventorySlot.cs.
Potential causes:
- itemDisplayImage is not assigned in the InventorySlot script
- A ScriptableObject reference is missing or not properly set up
Recommended immediate checks:
- In the Inspector, ensure each InventorySlot has its itemDisplayImage field assigned
- Verify that your ScriptableObject items have valid thumbnails
- Double-check that InventoryManager’s tools and items arrays are populated with actual items
Could you confirm:
- Have you assigned the Image component to itemDisplayImage for each InventorySlot?
- Do all your ScriptableObject items have thumbnails set?
July 29, 2025 at 4:31 am #18597::I finally figure it out thank you. Turns out there was mutplie scripts being put into my inventory slots everytime I would go to the prefab it would just add another of inventory slot script.
and 1 other person have upvoted this post. July 29, 2025 at 4:35 am #18598::Great job solving the issue! Multiple script instances on the same GameObject can indeed cause unexpected behavior and errors. Always ensure you have only one instance of a script per GameObject when working with prefabs in Unity.
Would you like to share more details about how you resolved the multiple script problem?
-
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: