Esempio n. 1
0
    private void loadJson()
    {
        Inventory inventory = new Inventory();

        JsonInterpreter.getDataFromJson <Inventory>(ref inventory, JsonInterpreter.getJsonFromFile("inventory"));
        if (null != inventory)
        {
            //create all dynamic slot
            foreach (Item item in inventory.items)
            {
                //instantiate slot
                GameObject SlotInstance = Instantiate(SlotPrefab);

                //update the item component
                ItemBehavior itemComponent = SlotInstance.GetComponent <ItemBehavior>();
                if (itemComponent)
                {
                    itemComponent.init(item);
                }

                //add to the grid
                SlotInstance.transform.SetParent(this.transform);
            }
        }
    }
    private void loadJson()
    {
        Inventory inventory = new Inventory();

        JsonInterpreter.getDataFromJson <Inventory>(ref inventory, JsonInterpreter.getJsonFromFile("inventory"));
        if (null != inventory)
        {
            Debug.Log(inventory.items.Length);
        }
    }