Наследование: MonoBehaviour
Пример #1
0
 public void addItemToInventory(int ignoreSlot, int itemID, int itemValue)
 {
     for (int i = 0; i < SlotContainer.transform.childCount; i++)
     {
         if (SlotContainer.transform.GetChild(i).childCount == 0 && i != ignoreSlot)
         {
             GameObject   item         = (GameObject)Instantiate(prefabItem);
             ItemOnObject itemOnObject = item.GetComponent <ItemOnObject>();
             itemOnObject.item = itemDatabase.getItemByID(itemID);
             if (itemOnObject.item.itemValue < itemOnObject.item.maxStack && itemValue <= itemOnObject.item.maxStack)
             {
                 itemOnObject.item.itemValue = itemValue;
             }
             else
             {
                 itemOnObject.item.itemValue = 1;
             }
             item.transform.SetParent(SlotContainer.transform.GetChild(i));
             item.GetComponent <RectTransform>().localPosition = Vector3.zero;
             itemOnObject.item.indexItemInList = 999;
             updateItemSize();
             stackableSettings();
             break;
         }
     }
     stackableSettings();
     updateItemList();
 }
Пример #2
0
 public void stackableSettings()
 {
     for (int i = 0; i < SlotContainer.transform.childCount; i++)
     {
         if (SlotContainer.transform.GetChild(i).childCount > 0)
         {
             ItemOnObject item = SlotContainer.transform.GetChild(i).GetChild(0)
                                 .GetComponent <ItemOnObject>();
             if (item.item.maxStack > 1)
             {
                 RectTransform textRectTransform = SlotContainer.transform.GetChild(i).GetChild(0)
                                                   .GetChild(1)
                                                   .GetComponent <RectTransform>();
                 Text text = SlotContainer.transform.GetChild(i).GetChild(0).GetChild(1)
                             .GetComponent <Text>();
                 text.text    = "" + item.item.itemValue;
                 text.enabled = stackable;
                 textRectTransform.localPosition = new Vector3(positionNumberX, positionNumberY, 0);
             }
             else
             {
                 Text text = SlotContainer.transform.GetChild(i).GetChild(0).GetChild(1)
                             .GetComponent <Text>();
                 text.enabled = false;
             }
         }
     }
 }
Пример #3
0
 public void addItemToInventoryStorage(int itemID, int value)
 {
     for (int i = 0; i < SlotContainer.transform.childCount; i++)
     {
         if (SlotContainer.transform.GetChild(i).childCount == 0)
         {
             GameObject   item         = (GameObject)Instantiate(prefabItem);
             ItemOnObject itemOnObject = item.GetComponent <ItemOnObject>();
             itemOnObject.item = itemDatabase.getItemByID(itemID);
             if (itemOnObject.item.itemValue < itemOnObject.item.maxStack && value <= itemOnObject.item.maxStack)
             {
                 itemOnObject.item.itemValue = value;
             }
             else
             {
                 itemOnObject.item.itemValue = 1;
             }
             item.transform.SetParent(SlotContainer.transform.GetChild(i));
             item.GetComponent <RectTransform>().localPosition = Vector3.zero;
             itemOnObject.item.indexItemInList = 999;
             if (inputManagerDatabase == null)
             {
                 inputManagerDatabase = (InputManager)Resources.Load("InputManager");
             }
             updateItemSize();
             stackableSettings();
             break;
         }
     }
     stackableSettings();
     updateItemList();
 }
Пример #4
0
    public GameObject addItemToInventory(int id, int value)
    {
        for (int i = 0; i < SlotContainer.transform.childCount; i++)
        {
            if (SlotContainer.transform.GetChild(i).childCount == 0)
            {
                GameObject   item         = (GameObject)Instantiate(prefabItem);
                ItemOnObject itemOnObject = item.GetComponent <ItemOnObject>();
                itemOnObject.item = itemDatabase.getItemByID(id);
                if (itemOnObject.item.itemValue <= itemOnObject.item.maxStack && value <= itemOnObject.item.maxStack)
                {
                    itemOnObject.item.itemValue = value;
                }
                else
                {
                    itemOnObject.item.itemValue = 1;
                }
                item.transform.SetParent(SlotContainer.transform.GetChild(i));
                item.GetComponent <RectTransform>().localPosition        = Vector3.zero;
                item.transform.GetChild(0).GetComponent <Image>().sprite = itemOnObject.item.itemIcon;
                itemOnObject.item.indexItemInList = ItemsInInventory.Count - 1;
                if (inputManagerDatabase == null)
                {
                    inputManagerDatabase = (InputManager)Resources.Load("InputManager");
                }
                return(item);
            }
        }

        stackableSettings();
        updateItemList();
        return(null);
    }
Пример #5
0
    public void OnPointerDown(PointerEventData data)                    //splitting the item now
    {
        inv = transform.parent.parent.parent.GetComponent <Inventory>();
        if (transform.parent.parent.parent.GetComponent <Hotbar>() == null && data.button == PointerEventData.InputButton.Left && pressingButtonToSplit && inv.stackable && (inv.ItemsInInventory.Count < (inv.height * inv.width))) //if you press leftclick and and keycode
        {
            ItemOnObject itemOnObject = GetComponent <ItemOnObject>();                                                                                                                                                               //we take the ItemOnObject script of the item in the slot

            if (itemOnObject.item.itemValue > 1)                                                                                                                                                                                     //we split the item only when we have more than 1 in the stack
            {
                int splitPart = itemOnObject.item.itemValue;                                                                                                                                                                         //we take the value and store it in there
                itemOnObject.item.itemValue = (int)itemOnObject.item.itemValue / 2;                                                                                                                                                  //calculate the new value for the splitted item
                splitPart = splitPart - itemOnObject.item.itemValue;                                                                                                                                                                 //take the different

                inv.addItemToInventory(itemOnObject.item.itemID, splitPart);                                                                                                                                                         //and add a new item to the inventory
                inv.stackableSettings();

                if (GetComponent <ConsumeItem>().duplication != null)
                {
                    GameObject dup = GetComponent <ConsumeItem>().duplication;
                    dup.GetComponent <ItemOnObject>().item.itemValue = itemOnObject.item.itemValue;
                    dup.GetComponent <SplitItem>().inv.stackableSettings();
                }
                inv.updateItemList();
            }
        }
    }
Пример #6
0
    public void OnPointerDown(PointerEventData data)
    {
        if (data.button == PointerEventData.InputButton.Right)
        {
            PlayerInterface.Instance.HideTooltip();

            _ItemOnObject = GetComponent <ItemOnObject>();
            item          = _ItemOnObject.Item;

            switch (_ItemOnObject.GetTypeParentinventory)
            {
            case Inventory.TypeParentInv.bag:
                BagUsage();
                break;

            case Inventory.TypeParentInv.equip:

                if (PlayerInterface.Instance.bagInv.AddItemToInventory(PlayerInterface.Instance.characterInv.GetEquipItem(item)))
                {
                    PlayerInterface.Instance.characterInv.UnEquip(item);
                }
                break;

            case Inventory.TypeParentInv.storage:
                StorageUsage();
                break;

            case Inventory.TypeParentInv.shop:
                // Add methods for shop
                break;

            case Inventory.TypeParentInv.hotbar:
                if (item.itemType == ItemType.Consume)
                {
                    // Add methods for usage hotbar
                }
                if (item.itemType == ItemType.Equip)
                {
                    // Add methods for usage hotbar
                }

                break;
            }
            item          = null;
            _ItemOnObject = null;
        }
        if (data.button == PointerEventData.InputButton.Left)
        {
            PlayerInterface.Instance.HideTooltip();
            _ItemOnObject = GetComponent <ItemOnObject>();
            item          = _ItemOnObject.Item;
            ActivateTooltip(data);
            item          = null;
            _ItemOnObject = null;
        }
    }
Пример #7
0
    private void AddResultItemInObj(Item tempItem)
    {
        tempItem.LoadResources();
        GameObject   itemObj       = (GameObject)Instantiate(itemCraftPrefab, slotResultTran, false);
        ItemOnObject _ItemOnObject = itemObj.GetComponent <ItemOnObject>();

        _ItemOnObject.Item = tempItem;
        _ItemOnObject.GetTypeParentinventory = typeParentInv;
        _ItemOnObject.UpdateItem();
    }
Пример #8
0
    protected void AddItemInObj(Item tempItem, int indexSlot)
    {
        if (itemTypesDB != null)
        {
            itemTypesDB.Add(new ItemTypesData(tempItem.id, tempItem.itemType));
        }
        tempItem.LoadResources();
        GameObject   itemObj       = (GameObject)Instantiate(prefabItem, slotContainer.GetChild(indexSlot), false);
        ItemOnObject _ItemOnObject = itemObj.GetComponent <ItemOnObject>();

        _ItemOnObject.Item = tempItem;
        //itemObj.transform.SetParent(slotContainer.transform.GetChild(i));
        //itemObj.GetComponent<RectTransform>().localPosition = Vector3.zero;
        _ItemOnObject.GetTypeParentinventory = typeParentInv;
        _ItemOnObject.UpdateItem();
    }
Пример #9
0
    public GameObject addItemToInventory(int itemId, UInt64 itemUUID, int value, int itemIndex)
    {
        if (itemIndex < 0 || itemIndex >= SlotContainer.transform.childCount)
        {
            return(null);
        }

        GameObject item = null;

        if (SlotContainer.transform.GetChild(itemIndex).childCount != 0)
        {
            item = SlotContainer.transform.GetChild(itemIndex).GetChild(0).gameObject;
        }
        else
        {
            item = (GameObject)Instantiate(prefabItem);
        }
        ItemOnObject itemOnObject = item.GetComponent <ItemOnObject>();

        itemOnObject.item           = itemDatabase.getItemByID(itemId);
        itemOnObject.item.itemUUID  = itemUUID;
        itemOnObject.item.itemIndex = itemIndex;
        if (itemOnObject.item.itemValue <= itemOnObject.item.maxStack && value <= itemOnObject.item.maxStack)
        {
            itemOnObject.item.itemValue = value;
        }
        else
        {
            itemOnObject.item.itemValue = 1;
        }
        item.transform.SetParent(SlotContainer.transform.GetChild(itemIndex));
        item.GetComponent <RectTransform>().localPosition        = Vector3.zero;
        item.transform.GetChild(0).GetComponent <Image>().sprite = itemOnObject.item.itemIcon;
        itemOnObject.item.indexItemInList = ItemsInInventory.Count - 1;
        if (inputManagerDatabase == null)
        {
            inputManagerDatabase = (InputManager)Resources.Load("InputManager");
        }
        return(item);

        //stackableSettings();
        //updateItemList();
        //return null;
    }
Пример #10
0
    private void AddItemInObj(RecipeCraft.Ingredient ingridient, int index)
    {
        ingridient.item.LoadResources();
        GameObject   itemObj       = (GameObject)Instantiate(itemCraftPrefab, slotContainerTran.GetChild(index), false);
        ItemOnObject _ItemOnObject = itemObj.GetComponent <ItemOnObject>();

        _ItemOnObject.Item = ingridient.item;
        _ItemOnObject.GetTypeParentinventory = typeParentInv;
        _ItemOnObject.UpdateItem();

        if (ingridient.IsEnough())
        {
            itemObj.transform.GetChild(1).GetComponent <Image>().color = greenSlotColor; //Child id 1 - Availability
        }
        else
        {
            itemObj.transform.GetChild(1).GetComponent <Image>().color = redSlotColor; //Child id 1 - Availability
        }
        _ItemOnObject.SetText(ingridient.GetQuantityText());
    }
Пример #11
0
    public void updateSlotAmount()
    {
        if (prefabSlot == null)
        {
            prefabSlot = Resources.Load("Prefabs/Slot - Inventory") as GameObject;
        }

        if (SlotContainer == null)
        {
            SlotContainer = (GameObject)Instantiate(prefabSlotContainer);
            SlotContainer.transform.SetParent(PanelRectTransform.transform);
            SlotContainerRectTransform = SlotContainer.GetComponent <RectTransform>();
            SlotGridRectTransform      = SlotContainer.GetComponent <RectTransform>();
            SlotGridLayout             = SlotContainer.GetComponent <GridLayoutGroup>();
        }

        if (SlotContainerRectTransform == null)
        {
            SlotContainerRectTransform = SlotContainer.GetComponent <RectTransform>();
        }
        SlotContainerRectTransform.localPosition = Vector3.zero;

        List <Item>       itemsToMove = new List <Item>();
        List <GameObject> slotList    = new List <GameObject>();

        foreach (Transform child in SlotContainer.transform)
        {
            if (child.tag == "Slot")
            {
                slotList.Add(child.gameObject);
            }
        }

        while (slotList.Count > width * height)
        {
            GameObject   go         = slotList[slotList.Count - 1];
            ItemOnObject itemInSlot = go.GetComponentInChildren <ItemOnObject>();
            if (itemInSlot != null)
            {
                itemsToMove.Add(itemInSlot.item);
                ItemsInInventory.Remove(itemInSlot.item);
            }
            slotList.Remove(go);
            DestroyImmediate(go);
        }

        if (slotList.Count < width * height)
        {
            for (int i = slotList.Count; i < (width * height); i++)
            {
                GameObject Slot = (GameObject)Instantiate(prefabSlot);
                Slot.name = (slotList.Count + 1).ToString();
                Slot.transform.SetParent(SlotContainer.transform);
                slotList.Add(Slot);
            }
        }

        if (itemsToMove != null && ItemsInInventory.Count < width * height)
        {
            foreach (Item i in itemsToMove)
            {
                addItemToInventory(i.itemID);
            }
        }

        setImportantVariables();
    }
Пример #12
0
    void ItemDataBase()
    {
        EditorGUILayout.BeginVertical("Box");

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.Width(position.width - 18));                                                    //creating a toolbar(tabs) to navigate what you wanna do
        GUILayout.EndHorizontal();

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

        GUILayout.Space(10);

        if (toolbarInt == 0)                                                                                                                              //if equal 0 than it is "Create Item"
        {
            GUI.color = Color.green;
            if (GUILayout.Button("Add Item", GUILayout.Width(position.width - 23)))
            {
                addItem();
                showItem = true;
            }

            if (showItem)
            {
                GUI.color = Color.white;

                GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23));
                try
                {
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemName, GUILayout.Width(position.width - 30)); //textfield for the itemname which you wanna create
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemID   = inventoryItemList.itemList.Count - 1;                                                                                                                    //itemID getting set automaticly ...its unique...better do not change it :D

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Item Description");                                                                                                                                                                                                                                             //label ItemDescription
                    GUILayout.Space(47);
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemDesc, GUILayout.Width(position.width - 180), GUILayout.Height(70));                                    //Text area for the itemDesc
                    GUILayout.EndHorizontal();
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemIcon  = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 33));           //objectfield for the itemicon for your new item
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 33)); //objectfield for the itemmodel for your new item

                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemType, GUILayout.Width(position.width - 33));                                   //the itemtype which you want to have can be selected with the enumpopup
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].maxStack, GUILayout.Width(position.width - 33));
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].rarity   = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].rarity, 0, 1000);
                    GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 33));
                    showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes");
                    if (showItemAttributes)
                    {
                        GUILayout.BeginHorizontal();
                        addAttributeName = EditorGUILayout.TextField("Name", addAttributeName);
                        GUI.color        = Color.green;
                        if (GUILayout.Button("Add"))
                        {
                            addAttribute();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.Space(10);
                        GUI.color = Color.white;
                        EditorGUI.BeginChangeCheck();
                        attributeAmount = EditorGUILayout.IntSlider("Amount", attributeAmount, 0, 50);
                        if (EditorGUI.EndChangeCheck())
                        {
                            attributeName  = new int[attributeAmount];
                            attributeValue = new int[attributeAmount];
                        }

                        string[] attributes = new string[itemAttributeList.itemAttributeList.Count];
                        for (int i = 1; i < attributes.Length; i++)
                        {
                            attributes[i] = itemAttributeList.itemAttributeList[i].attributeName;
                        }


                        for (int k = 0; k < attributeAmount; k++)
                        {
                            EditorGUILayout.BeginHorizontal();
                            attributeName[k]  = EditorGUILayout.Popup("Attribute " + (k + 1), attributeName[k], attributes, EditorStyles.popup);
                            attributeValue[k] = EditorGUILayout.IntField("Value", attributeValue[k]);
                            EditorGUILayout.EndHorizontal();
                        }
                        if (GUILayout.Button("Save"))
                        {
                            List <ItemAttribute> iA = new List <ItemAttribute>();
                            for (int i = 0; i < attributeAmount; i++)
                            {
                                iA.Add(new ItemAttribute(attributes[attributeName[i]], attributeValue[i]));
                            }
                            inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemAttributes = iA;
                            showItem = false;
                        }
                    }
                    GUILayout.EndVertical();
                    inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].indexItemInList = 999;
                }
                catch { }
                GUILayout.EndVertical();
            }
        }

        if (toolbarInt == 1)                                                            //if toolbar equals 1...manage items...alle items are editable here
        {
            if (inventoryItemList == null)
            {
                inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase");
            }
            if (inventoryItemList.itemList.Count == 1)                                  //if there is no item in the database you get this...yes it is right to have == 1
            {
                GUILayout.Label("There is no Item in the Database!");                   //information that you do not have one
            }
            else
            {
                GUILayout.BeginVertical();
                for (int i = 1; i < inventoryItemList.itemList.Count; i++)                      //get through all items which are there in the itemdatabase
                {
                    try
                    {
                        manageItem.Add(false);                                                                               //foldout is closed at default
                        GUILayout.BeginVertical("Box");
                        manageItem[i] = EditorGUILayout.Foldout(manageItem[i], "" + inventoryItemList.itemList[i].itemName); //create for every item which you have in the itemdatabase a foldout
                        if (manageItem[i])                                                                                   //if you press on it you get this
                        {
                            EditorUtility.SetDirty(inventoryItemList);                                                       //message the scriptableobject that you change something now
                            GUI.color = Color.red;                                                                           //all upcoming GUIelements get changed to red
                            if (GUILayout.Button("Delete Item"))                                                             //create button that deletes the item
                            {
                                inventoryItemList.itemList.RemoveAt(i);                                                      //remove the item out of the itemdatabase
                                EditorUtility.SetDirty(inventoryItemList);                                                   //and message the database again that you changed something
                            }

                            GUI.color = Color.white;                                                                                                                                       //next GUIElements will be white
                            inventoryItemList.itemList[i].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[i].itemName, GUILayout.Width(position.width - 45)); //textfield for the itemname which you wanna create
                            inventoryItemList.itemList[i].itemID   = i;                                                                                                                    //itemID getting set automaticly ...its unique...better do not change it :D
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Item ID");
                            GUILayout.Label("" + i);
                            GUILayout.EndHorizontal();
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Item Description");                                                                                                                                                                       //label ItemDescription
                            GUILayout.Space(47);
                            inventoryItemList.itemList[i].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[i].itemDesc, GUILayout.Width(position.width - 195), GUILayout.Height(70));                                    //Text area for the itemDesc
                            GUILayout.EndHorizontal();
                            inventoryItemList.itemList[i].itemIcon  = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[i].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 45));           //objectfield for the itemicon for your new item
                            inventoryItemList.itemList[i].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[i].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 45)); //objectfield for the itemmodel for your new item
                            inventoryItemList.itemList[i].itemType  = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[i].itemType, GUILayout.Width(position.width - 45));                                  //the itemtype which you want to have can be selected with the enumpopup
                            inventoryItemList.itemList[i].maxStack  = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[i].maxStack, GUILayout.Width(position.width - 45));
                            inventoryItemList.itemList[i].rarity    = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[i].rarity, 0, 1000);
                            GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 45));
                            showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes");
                            if (showItemAttributes)
                            {
                                string[] attributes = new string[itemAttributeList.itemAttributeList.Count];
                                for (int t = 1; t < attributes.Length; t++)
                                {
                                    attributes[t] = itemAttributeList.itemAttributeList[t].attributeName;
                                }


                                if (inventoryItemList.itemList[i].itemAttributes.Count != 0)
                                {
                                    for (int t = 0; t < inventoryItemList.itemList[i].itemAttributes.Count; t++)
                                    {
                                        for (int z = 1; z < attributes.Length; z++)
                                        {
                                            if (inventoryItemList.itemList[i].itemAttributes[t].attributeName == attributes[z])
                                            {
                                                attributeNamesManage[t] = z;
                                                attributeValueManage[t] = inventoryItemList.itemList[i].itemAttributes[t].attributeValue;
                                                break;
                                            }
                                        }
                                    }
                                }

                                for (int z = 0; z < inventoryItemList.itemList[i].itemAttributes.Count; z++)
                                {
                                    EditorGUILayout.BeginHorizontal();
                                    GUI.color = Color.red;
                                    if (GUILayout.Button("-"))
                                    {
                                        inventoryItemList.itemList[i].itemAttributes.RemoveAt(z);
                                    }
                                    GUI.color = Color.white;
                                    attributeNamesManage[z] = EditorGUILayout.Popup(attributeNamesManage[z], attributes, EditorStyles.popup);
                                    inventoryItemList.itemList[i].itemAttributes[z].attributeValue = EditorGUILayout.IntField("Value", inventoryItemList.itemList[i].itemAttributes[z].attributeValue);
                                    EditorGUILayout.EndHorizontal();
                                }
                                GUI.color = Color.green;
                                if (GUILayout.Button("+"))
                                {
                                    inventoryItemList.itemList[i].itemAttributes.Add(new ItemAttribute());
                                }



                                GUI.color = Color.white;
                                if (GUILayout.Button("Save"))
                                {
                                    List <ItemAttribute> iA = new List <ItemAttribute>();
                                    for (int k = 0; k < inventoryItemList.itemList[i].itemAttributes.Count; k++)
                                    {
                                        iA.Add(new ItemAttribute(attributes[attributeNamesManage[k]], attributeValueManage[k]));
                                    }
                                    inventoryItemList.itemList[i].itemAttributes = iA;

                                    GameObject[] items = GameObject.FindGameObjectsWithTag("Item");
                                    for (int z = 0; z < items.Length; z++)
                                    {
                                        ItemOnObject item = items[z].GetComponent <ItemOnObject>();
                                        if (item.item.itemID == inventoryItemList.itemList[i].itemID)
                                        {
                                            int value = item.item.itemValue;
                                            item.item           = inventoryItemList.itemList[i];
                                            item.item.itemValue = value;
                                        }
                                    }

                                    manageItem[i] = false;
                                }
                            }
                            GUILayout.EndVertical();

                            EditorUtility.SetDirty(inventoryItemList);                                                                                              //message scriptable object that you have changed something
                        }
                        GUILayout.EndVertical();
                    }
                    catch { }
                }
                GUILayout.EndVertical();
            }
        }
        if (inventoryItemList == null)
        {
            inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase");
        }

        EditorGUILayout.EndScrollView();

        EditorGUILayout.EndVertical();
    }