Search Unity

Inventory System Tutorial in Unity 5 by AwfulMedia

Discussion in 'Community Learning & Teaching' started by Austin-Gregory, Sep 15, 2015.

  1. Austin-Gregory

    Austin-Gregory

    Joined:
    Sep 19, 2013
    Posts:
    78


    The Inventory
    Learn how to create an Inventory System in Unity 5 using JSON as your database. Features such as tooltips, item stacking, drag and drop, consumables, and more!

    The Inventory will be shaped based on viewer feedback so be sure to leave comments on the videos!

    The Playlist
    Seeing as this will be quite a lengthy series, I'll only link the playlist and not embed each part here.
    Click here to check it out!
     
    Deleted User and JoakimCarlsson like this.
  2. JoakimCarlsson

    JoakimCarlsson

    Joined:
    Aug 27, 2014
    Posts:
    65
    Great to see new videos coming up from you. Keep up the fantastic work.
     
  3. Paykoman

    Paykoman

    Joined:
    Jun 26, 2014
    Posts:
    500
    W8 for that.. hope u make a nice database tutorial for the inventory and if possible a character windows to use items ;)
     
  4. Cainebog

    Cainebog

    Joined:
    Jul 15, 2015
    Posts:
    8
    I am enjoying the tutorial, keep up the good work.

    I hope this thread is still running. So here's my problem... I am working through tutorial 3 in the series but have a error I picked in tutorial 2 regarding the reading of Json files. The error is as follows

    NullReferenceException: Object reference not set to an instance of an object
    ItemDatabase.Start () (at Assets/Scripts/ItemDatabase.cs:21)

    Here is the fragment of code it refers to:

    void Start()
    {
    itemData = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/StreamingAssets/items.json"));

    Debug.Log(FetchItemByID(1).Description);

    }

    public Item FetchItemByID(int id) // (This is line 21)
    {
    for (int i = 0; i < database.Count; i++)
    {
    if (database.ID == id)
    return database;
    }
    return null;
    }

    I have spent some hours looking into possible sources, but the code for the ItemDatabse class is free of syntax errors. I am using visual studio 2015 and the Litjson.dll is attached in the unity editor and is referenced in the VS studio. SO I 'm a little stuck.

    Any pointers or suggestions are welcome.
     
    Last edited: Aug 13, 2016