So, I have this inventory system that reads in a json database and fills in item data. It’s working fine in the editor but not on my android. Works fine in windows, but I have to manually go in and paste the json into the data folders. Any help on getting android to recognize this? The problem is definitely in android not finding the Json.
The top 3 commented out lines were what I was trying, but kept getting errors. I get NullReferenceException on the string content = text.ToString(); line.
void Start()
{
//text = Resources.Load<TextAsset>("Items.json");
//string content = text.ToString();
//itemData = JsonMapper.ToObject(File.ReadAllText(content));
itemData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/Resources/Items.json"));
ConstructItemDatabase();
}
public Item FetchItemByID(int id)
{
for (int i = 0; i < database.Count; i++)
{
if (database*.ID == id)*
{
return database*;*
}
}
return null;
}
void ConstructItemDatabase()
{
for (int i = 0; i < itemData.Count; i++)
database.Add(new Item((int)itemData[“id”], itemData[“title”].ToString(), (int)itemData[“rarity”], itemData[“description”].ToString(), itemData[“classes”].ToString(),itemData[“spritelocation”].ToString(),(int)itemData[“equipslot”], itemData_[“prefablocation”].ToString(),(bool)itemData*[“stackable”]));
}
}*_