Unity Inventory Database ID Error
Hi. I am trying to make an inventory following this tutorial [https://www.youtube.com/watch?v=x24t4DCxGh8]. I have exactly what he has except I added a few values and changed some names since I am making a game of my own. All I want is an inventory and this just isnt working. Any idea why?
Here are my Errors:
Assets/Inventory System/Scripts/ItemDatabase.cs(24,41): error CS0122: Item.ID' is inaccessible due to its protection level Assets/Inventory System/Scripts/ItemDatabase.cs(36,170): error CS1502: The best overloaded method match for
Item.Item(int, string, int, int, int, int, int, int, string, bool, string)' has some invalid arguments
Assets/Inventory System/Scripts/ItemDatabase.cs(36,170): error CS1503: Argument #11' cannot convert
method group' expression to type string' Assets/Inventory System/Scripts/ItemDatabase.cs(34,34): error CS1502: The best overloaded method match for
System.Collections.Generic.List.Add(Item)' has some invalid arguments
Assets/Inventory System/Scripts/ItemDatabase.cs(34,34): error CS1503: Argument #1' cannot convert
object' expression to type `Item'
Here are my scripts:
ItemDatabase.cs -- [http://pastebin.com/fezdVcfm]
Items.json -- [http://pastebin.com/BnPWenpt]
Thanks in advance for anyone who can help me!
Answer by corn · Jan 04, 2016 at 05:07 PM
Item.ID is private. You need to change ItemDatabase.cs l60
private int ID{get; set;}
to
int ID{public get; private set;}
You also made a typo l34, for the last argument of Item.Item :
(..., itemData[i]["slug"].ToString) );
should be :
(..., itemData[i]["slug"].ToString() ) );